/**
* 读取doc的表格数据
* @param docPath
*/
public static void readDocTable(String docPath){
try {
FileInputStream in = new FileInputStream(docPath);
HWPFDocument hwpf = new HWPFDocument(in);//载入文档
Range range = hwpf.getRange();//得到文档读取范围
TableIterator iterator = new TableIterator(range);
//迭代文档中的表格
while(iterator.hasNext()){
Table table = iterator.next();
System.out.println("===========Table");
//迭代行,默认从0开始
for(int row = 0; row < table.numRows(); row ++){
System.out.println("===Table Row=" + row);
TableRow tableRow = table.getRow(row);
//迭代列,默认从0开始
for(int colum = 0; colum <tableRow.numCells(); colum ++){
TableCell tableCell = tableRow.getCell(colum);
//取得单元格的内容
for(int cell = 0; cell < tableCell.numParagraphs(); cell ++){
org.apache.poi.hwpf.usermodel.Paragraph paragraph = tableCell.getParagraph(cell);
String text = paragraph.text();
System.out.println("Table colum=" + colum + ",text=" + text);
}
}
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
分享到:
相关推荐
VC读取doc,excel,pdf,ppt的内容,注意首先的需要用管理员权限在dos下注册ExtractText.dll,
java读取doc文档的一些小例子,供大家参考。
java文件读取方法.docjava文件读取方法.docjava文件读取方法.docjava文件读取方法.doc
Android上实现的读取DOC文件的程序,需要第三方jar,在压缩文件中一并送上。
读取和创建doc文档文件读取word文档
c#读取doc,docx
如何在Shell脚本中逐行读取文件.doc
VB读取excel表.doc
使用java方便读取word 中的内容,效率高
Java循环读取1指定目录下的文件.docJava循环读取1指定目录下的文件.docJava循环读取1指定目录下的文件.docJava循环读取1指定目录下的文件.docJava循环读取1指定目录下的文件.docJava循环读取1指定目录下的文件.doc...
python读取xml文件.doc
java版本,读取doc、rtf文档内容,解决中文乱码问题,log4j日志记录,使用swing进行rtf内容读取
matlab读取excel-matlab读取excel.doc matlab读取excel,有需要的朋友可以看看,^_^
java读取doc,docx文档所必备的一些jar整理如下,敬请参考。
数据字典和数据表的读取、T-code.doc
NET中将doc文件读取为XmlDocumen
(完整word版)VB读取excel表.doc
java 读取doc,docx,txt文件,代码已做了很好的封装,可以在项目中使用!有问题给我发邮箱!