怎样在Android中解析doc、docx、xls、xlsx格式文件?
来源:互联网 发布:three.js全景源码特效 编辑:程序博客网 时间:2024/04/27 20:41
可以直接复制实验,
解析doc,要tm-extractors-0.4.jar这个包
解析xls,要jxl.jar这个包
解析xls
解析doc,要tm-extractors-0.4.jar这个包
解析xls,要jxl.jar这个包
01
public
static
String readDOC(String path) {
02
// 创建输入流读取doc文件
03
FileInputStream in;
04
String text =
null
;
05
// Environment.getExternalStorageDirectory().getAbsolutePath()+ "/aa.doc")
06
try
{
07
in =
new
FileInputStream(
new
File(path));
08
int
a= in.available();
09
WordExtractor extractor =
null
;
10
// 创建WordExtractor
11
extractor =
new
WordExtractor();
12
// 对doc文件进行提取
13
text = extractor.extractText(in);
14
System.out.println(
"解析得到的东西"
+text);
15
}
catch
(FileNotFoundException e) {
16
e.printStackTrace();
17
}
catch
(Exception e) {
18
e.printStackTrace();
19
}
20
if
(text ==
null
) {
21
text =
"解析文件出现问题"
;
22
}
23
return
text;
24
}
01
public
static
String readXLS(String path) {
02
String str =
""
;
03
try
{
04
Workbook workbook =
null
;
05
workbook = Workbook.getWorkbook(
new
File(path));
06
Sheet sheet = workbook.getSheet(
0
);
07
Cell cell =
null
;
08
int
columnCount = sheet.getColumns();
09
int
rowCount = sheet.getRows();
10
for
(
int
i =
0
; i < rowCount; i++) {
11
for
(
int
j =
0
; j < columnCount; j++) {
12
cell = sheet.getCell(j, i);
13
String temp2 =
""
;
14
if
(cell.getType() == CellType.NUMBER) {
15
temp2 = ((NumberCell) cell).getValue() +
""
;
16
}
else
if
(cell.getType() == CellType.DATE) {
17
temp2 =
""
+ ((DateCell) cell).getDate();
18
}
else
{
19
temp2 =
""
+ cell.getContents();
20
}
21
str = str +
" "
+ temp2;
22
}
23
str +=
"\n"
;
24
}
25
workbook.close();
26
}
catch
(Exception e) {
27
}
28
if
(str ==
null
) {
29
str =
"解析文件出现问题"
;
30
}
31
return
str;
32
}
- 怎样在Android中解析doc、docx、xls、xlsx格式文件?
- 怎样在Android中解析doc、docx、xls、xlsx格式文件?
- 怎样在Android中解析doc、docx、xls、xlsx格式文件?
- 怎样在Android中解析doc、docx、xls、xlsx格式文件?
- 怎样在Android中解析doc、docx、xls、xlsx格式文件?
- Android中解析doc、docx、xls、xlsx格式文件
- Android中解析doc、docx、xls、xlsx格式文件
- Android中解析doc、docx、xls、xlsx格式文件
- android中解析doc、docx、xls、xlsx格式文件
- 在Android中解析doc,docx,xls,xlsx,pptx等格式文件
- 怎样在Android中解析doc、docx、xls、xlsx格式文
- android中如何读写.doc、.docx、.xls、.xlsx格式文件
- android解析doc,docx,xls,xlsx文件
- Android打开 解析 doc,docx,xls,xlsx,ppt等格式文件的源码
- 在网页中在线查看文档(doc、docx 、xls 、xlsx、 pdf 、swf )
- Android中pdf,doc,docx,xls,xlsx,ppt,pptx等office文件预览
- POI解析文档内容(txt,doc,docx,xls,xlsx,ppt,pdf)
- android 打开 ppt pptx doc docx xls xlsx pdf office 文档
- 虚拟机安装LINUX等系统,设置系统桌面分辨率或与本机文件拷贝。
- 主面板上面CEdit控件显示输出信息
- http://www.jdon.com/
- Linux终端tty设备及驱动
- Xlib Programming Manual
- 怎样在Android中解析doc、docx、xls、xlsx格式文件?
- 程序设计方法-回溯、概率、启发式
- java视频教程免费下载
- Java计算程序运行时间
- 将一个图片切割成多个图片
- 1000:A+B problem
- GTK+, Qt, wxWidgets 比较简评
- VC6.0中怎样引入lib文件
- Nginx 简单的负载均衡配置示例