- 浏览: 129283 次
- 性别:
- 来自: 北京
最新评论
-
qiuhuahui1:
真的有用,帮我节省了大把的时间。
android的ant编译打包 -
fxiaozj:
楼主,有没有demo?
Android ViewGroup实现页面滑动效果并实现不同的动画效果 -
sgjsdf5944:
你好,请问下楼主如果我想在安装完成页面上控制打开不可用该怎么实 ...
Android 监控程序安装和删除的实现 -
renfujiang:
养成好习惯,看过别人的文章 就得评论 增加点人气 好文章 我是 ...
android的ant编译打包 -
leishengwei:
你好,第一种方法在4.0时,输入法是弹不出去了,但是光标不能正 ...
Android如何关闭EditText中的软键盘
有的时候我们在开发android中需要解析一些我们比较常用的格式,比如doc、docx、xls、xlsx,那么我们要是正常的话就解析不了。这时我们就要用tm-extractors-0.4.jar。
解析doc,要tm-extractors-0.4.jar这个包
解析xls,要jxl.jar这个包
解析doc,要tm-extractors-0.4.jar这个包
解析xls,要jxl.jar这个包
public static String readDOC(String path) { // 创建输入流读取doc文件 FileInputStream in; String text = null; // Environment.getExternalStorageDirectory().getAbsolutePath()+ "/aa.doc") try { in = new FileInputStream(new File(path)); int a= in.available(); WordExtractor extractor = null; // 创建WordExtractor extractor = new WordExtractor(); // 对doc文件进行提取 text = extractor.extractText(in); System.out.println("解析得到的东西"+text); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } if (text == null) { text = "解析文件出现问题"; } return text; }
public static String readXLS(String path) { String str = ""; try { Workbook workbook = null; workbook = Workbook.getWorkbook(new File(path)); Sheet sheet = workbook.getSheet(0); Cell cell = null; int columnCount = sheet.getColumns(); int rowCount = sheet.getRows(); for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { cell = sheet.getCell(j, i); String temp2 = ""; if (cell.getType() == CellType.NUMBER) { temp2 = ((NumberCell) cell).getValue() + ""; } else if (cell.getType() == CellType.DATE) { temp2 = "" + ((DateCell) cell).getDate(); } else { temp2 = "" + cell.getContents(); } str = str + " " + temp2; } str += "\n"; } workbook.close(); } catch (Exception e) { } if (str == null) { str = "解析文件出现问题"; } return str; }
public static String readDOCX(String path) { String river = ""; try { ZipFile xlsxFile = new ZipFile(new File(path)); ZipEntry sharedStringXML = xlsxFile.getEntry("word/document.xml"); InputStream inputStream = xlsxFile.getInputStream(sharedStringXML); XmlPullParser xmlParser = Xml.newPullParser(); xmlParser.setInput(inputStream, "utf-8"); int evtType = xmlParser.getEventType(); while (evtType != XmlPullParser.END_DOCUMENT) { switch (evtType) { case XmlPullParser.START_TAG: String tag = xmlParser.getName(); System.out.println(tag); if (tag.equalsIgnoreCase("t")) { river += xmlParser.nextText() + "\n"; } break; case XmlPullParser.END_TAG: break; default: break; } evtType = xmlParser.next(); } } catch (ZipException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (XmlPullParserException e) { e.printStackTrace(); } if (river == null) { river = "解析文件出现问题"; } return river; }
public static String readXLSX(String path) { String str = ""; String v = null; boolean flat = false; List<String> ls = new ArrayList<String>(); try { ZipFile xlsxFile = new ZipFile(new File(path)); ZipEntry sharedStringXML = xlsxFile .getEntry("xl/sharedStrings.xml"); InputStream inputStream = xlsxFile.getInputStream(sharedStringXML); XmlPullParser xmlParser = Xml.newPullParser(); xmlParser.setInput(inputStream, "utf-8"); int evtType = xmlParser.getEventType(); while (evtType != XmlPullParser.END_DOCUMENT) { switch (evtType) { case XmlPullParser.START_TAG: String tag = xmlParser.getName(); if (tag.equalsIgnoreCase("t")) { ls.add(xmlParser.nextText()); } break; case XmlPullParser.END_TAG: break; default: break; } evtType = xmlParser.next(); } ZipEntry sheetXML = xlsxFile.getEntry("xl/worksheets/sheet1.xml"); InputStream inputStreamsheet = xlsxFile.getInputStream(sheetXML); XmlPullParser xmlParsersheet = Xml.newPullParser(); xmlParsersheet.setInput(inputStreamsheet, "utf-8"); int evtTypesheet = xmlParsersheet.getEventType(); while (evtTypesheet != XmlPullParser.END_DOCUMENT) { switch (evtTypesheet) { case XmlPullParser.START_TAG: String tag = xmlParsersheet.getName(); if (tag.equalsIgnoreCase("row")) { } else if (tag.equalsIgnoreCase("c")) { String t = xmlParsersheet.getAttributeValue(null, "t"); if (t != null) { flat = true; System.out.println(flat + "有"); } else { System.out.println(flat + "没有"); flat = false; } } else if (tag.equalsIgnoreCase("v")) { v = xmlParsersheet.nextText(); if (v != null) { if (flat) { str += ls.get(Integer.parseInt(v)) + " "; } else { str += v + " "; } } } break; case XmlPullParser.END_TAG: if (xmlParsersheet.getName().equalsIgnoreCase("row") && v != null) { str += "\n"; } break; } evtTypesheet = xmlParsersheet.next(); } System.out.println(str); } catch (ZipException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (XmlPullParserException e) { e.printStackTrace(); } if (str == null) { str = "解析文件出现问题"; } return str; }
发表评论
-
ListView与Button、imageButton 的共存问题解决
2013-02-20 11:39 1308ListView与Button、imageButton 的共存 ... -
android实现popupwindow的动画效果
2013-02-01 18:56 1994问题:在打开或者关闭popupwindow的时候怎么样显示动画 ... -
Android开发ViewPager中ListView失效问题解决方法
2013-01-28 22:12 2755最近开发一个Android小应用。就是利用ViewPager实 ... -
Android ViewGroup实现页面滑动效果并实现不同的动画效果
2012-08-28 22:24 3122这应该是自己第一次开始写博客,今天起想要记录下自己工作上学到的 ... -
关于WebView的loadData方法以及乱码问题
2012-08-09 14:37 956WebView是Android应用开发 ... -
Android对图片的压缩读取和保存
2012-08-08 10:27 1375在开发图片浏览器等软件是,很多时候要显示图片的缩略图,而一般情 ... -
ubuntu下载android源代码
2012-07-22 00:50 1900用虚拟机来创建一个Ubun ... -
android面试(2)
2012-07-20 16:17 1068附带答案,共100分 一、选择题(30题,每题1.5分,共4 ... -
自定义PreferenceActivity——修改Preference样式、加顶部布局
2012-05-27 20:19 2686首先在res/xml文件夹下建立preferences.xml ... -
android拦截短信并屏蔽系统的Notification
2012-05-21 09:25 1785Android短信拦截,总的来说有两种方式: (一)、在代码 ... -
Android设置应用程序默认语言
2012-05-19 21:03 1521Android应用程序的国际化还是做得不错的,通过设置资源文件 ... -
(android 实战总结)android对html支持接口总结
2012-04-18 09:50 2374Android支持html 的两个接口 1 Spanned ... -
Android的TextView使用Html来处理图片显示、字体样式、超链接等
2012-04-16 11:09 1553转eoe:http://www.eoeandroid.com/ ... -
android的ant编译打包
2012-04-11 14:52 3904Android本身是支持ant打包项目的,并且SDK中自带一个 ... -
使用InputStreamEntity 边读取边上传文件
2012-04-09 17:32 7424HttpClient httpclient = new Def ... -
android xliff字符串操作
2012-04-09 14:59 1411参考:http://blog.csdn.net/freshma ... -
Android:只读EditText内容可滚动(禁止输入法)的实现
2012-04-06 12:00 1393实验设备为HTC hero (SDK 2.1-update1) ... -
Eclipse报内存溢出
2012-04-04 10:50 1098(1)在配置tomcat的JDK里面设置。Window--&g ... -
Android解压缩zip的实现
2012-03-20 11:21 2824android 解压缩zip包,需要在menifest.xml ... -
Android alertdialog的按钮点击后不消失
2012-03-15 20:35 1860使用反射: 在你的setPositiveButton中添加 ...
相关推荐
安卓解析word文档 webView显示 花了三天写出来的 翻遍了网上所有的资料 可解析 doc docx xls xlsx格式 完整代码 里面带poi的包 所以有点大
android 操作office文档 doc docx xls xlsx ppt pptx pdf
把office解析成html并保存显示,doc可以解析图片等。。
office办公文档doc、docx、xls、xlsx、ppt、pptx在线预览java代码,本项目为springboot项目,方便搭建运行
使用POI将office(doc/docx/ppt/pptx/xls/xlsx)文件转html格式
android读取doc/docx/xls转换为html,亲测可用。费了好大力气,终于把它搞定了!
使用spring boot打造文件文档在线预览项目解决方案,支持doc、docx、ppt、pptx、xls、xlsx、zip、rar、mp4、mp3以及众多类文本如txt、html、xml、java、properties、sql、js、md、json、conf、ini、vue、php、py、...
读取txt、doc、docx、pptx、xls、xlsx,以及文件下载 需要下载jxl和tm
支持word2003的文件格式分析(doc, xls, ppt),也支持(docx, xlsx, pptx)文件格式分析,全图形化界面工具; 本人也在从事pdf, word2003, openxml文件格式相关开发
使用poi,pdfbox读取doc,docs,ppt,pptx,xls,xlsx,pdf,txt等各类文件内容,包含代码和jar包
基于POI修改的,支持android 本地解析,本地浏览,无需联网,编译通过后,打开app,点击按钮“选择TXT文件”,选择doc或docx或。。。然后点击相应的文件名即可打开预览
基于poi实现word/excel转换为HTML(且兼容.doc.docx.xls.xlsx) 对于简单的word Excel 转换 足够。excel转换时存在火狐浏览器不兼容乱码问题,希望多多交流。
office文件(含doc,docx,xls,xlsx,ppt,pptx等)转PDF生成(C#程序)
.pdf/.doc/.docx/.xls/.xlsx/.ppt/.pptx 文件网页预览 ASP.NET MVC 项目
lucene.net 用于doc,docx,xls,xlsx,ppt,pptx,pdf等文件检索,该程序是将文件中文本提取出来,然后创建检索,效果很好!
Linux命令行实现在线预览PPT,PPTX,DOC,DOCX,XLS,XLSX文件,可以实现xlsx文件转txt文件,文档内是安装插件详细步骤
Spring boot 在线预览办公文件(doc、docx、xls、xlsx、pdf等),转化效果个人觉得比较理想
B: office word文件 ".doc", ".odt", ".docx", ".dotm", ".docm" C: wps文档 ".wps" D: office excel文件 ".xls", ".xlsx", ".xlsm", ".xltm" E: wps表格 ".et" F: office powerPoint文件 ".ppt", ".pptx", ".potm",...
java解析pdf,zip,doc,xls等格式,解压就可运行
B: office word文件 ".doc", ".odt", ".docx", ".dotm", ".docm" C: wps文档 ".wps" D: office excel文件 ".xls", ".xlsx", ".xlsm", ".xltm" E: wps表格 ".et" F: office powerPoint文件 ".ppt", ".pptx", ".potm",...