package com.example; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.usermodel.*; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import java.io.FileInputStream; public class wordPdf { public static void main(String[] args) { try{ FileInputStream in = new FileInputStream("/Users/wangrongfei/Downloads/中国标准文献分类号CCS.doc");// 载入文档 POIFSFileSystem pfs = new POIFSFileSystem(in); HWPFDocument hwpf = new HWPFDocument(pfs); Range range = hwpf.getRange();// 得到文档的读取范围 TableIterator it = new TableIterator(range); String[] stu = new String[5]; // 迭代文档中的表格 while (it.hasNext()) { Table tb = (Table) it.next(); // 迭代行,默认从0开始 for (int i = 0; i < tb.numRows(); i++) { TableRow tr = tb.getRow(i); // 迭代列,默认从0开
java 读取word文件
最新推荐文章于 2024-05-26 18:08:28 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)