使用POI对word文档进行取读

导入POI包

 <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --><dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.17</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.poi/poi-examples --><dependency><groupId>org.apache.poi</groupId><artifactId>poi-examples</artifactId><version>3.17</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.poi/poi-excelant --><dependency><groupId>org.apache.poi</groupId><artifactId>poi-excelant</artifactId><version>3.17</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>3.17</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas --><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml-schemas</artifactId><version>3.17</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad --><dependency><groupId>org.apache.poi</groupId><artifactId>poi-scratchpad</artifactId><version>3.17</version></dependency>

word简单表格

    public Object wordscience(@RequestParam(value = "file", required = false) MultipartFile file) throws Exception {Map<String, Object> map = new HashMap<String, Object>();String errInfo = "success";InputStream ins = null;ins = file.getInputStream();while (it.hasNext()) {PageData savePd = new PageData();XWPFTable table = it.next();//System.out.println("这是第" + num + "个表的数据");List<XWPFTableRow> rows = table.getRows();XWPFTableRow rowOne = rows.get(0);String stringOne = rowOne.getTableCells().get(0).getText();if (stringOne.equals("测试")) {//读取每一行数据for (int i = 0; i < rows.size(); i++) {XWPFTableRow row = rows.get(i);//读取每一列数据List<XWPFTableCell> cells = row.getTableCells();for (int j = 0; j < cells.size(); j++) {XWPFTableCell cell = cells.get(j);//cell.setText("66666666666666666啊");//输出当前的单元格的数据System.out.print(cell.getText() + "\t");if (cell.getText().equals("测试1")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试2")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试3")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试4")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试5")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试6")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试7")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试8")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试9")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试10")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试11")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试12")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试13")) {savePd.put("projectname1", cells.get(j + 1).getText());}if (cell.getText().equals("测试14")) {savePd.put("projectname1", cells.get(j + 1).getText());}
}
}

word列表

  public Object wordscience(@RequestParam(value = "file", required = false) MultipartFile file) throws Exception {Map<String, Object> map = new HashMap<String, Object>();String errInfo = "success";InputStream ins = null;ins = file.getInputStream();while (it.hasNext()) {PageData savePd = new PageData();XWPFTable table = it.next();//System.out.println("这是第" + num + "个表的数据");List<XWPFTableRow> rows = table.getRows();XWPFTableRow rowOne = rows.get(0);String stringOne = rowOne.getTableCells().get(0).getText();if (stringOne.equals("测试1")) {//读取每一行数据for (int i = 2; i < rows.size(); i++) {XWPFTableRow row = rows.get(i);//读取每一列数据List<XWPFTableCell> cells = row.getTableCells();PageData newsavePd = new PageData();newsavePd.put("12", office_id);newsavePd.put("12", cells.get(0).getText());newsavePd.put("12", cells.get(1).getText());newsavePd.put("12", cells.get(2).getText());newsavePd.put("12", cells.get(3).getText());newsavePd.put("12", cells.get(4).getText());newsavePd.put("12", cells.get(5).getText());newsavePd.put("12", juser.get("ID"));newsavePd.put("12", juser.get("NAME"));newsavePd.put("12", newdate);criticalnodeService.save(newsavePd);}}
}
}


杜兰特下赛季加油,篮网冲冲冲!!!

使用POI对word文档进行取读相关推荐

  1. poi操作word文档总结

    POI分段落生成纯Word动态模板并导入数据 导出数据,可以用word另存为xml格式的ftl文件,变量用${变量名}表示,然后在类中通过 freemarker去替换变量. 但是怎么导入word数据. ...

  2. POI生成word文档完整案例及讲解

    一,网上的API讲解 其实POI的生成Word文档的规则就是先把获取到的数据转成xml格式的数据,然后通过xpath解析表单式的应用取值,判断等等,然后在把取到的值放到word文档中,最后在输出来. ...

  3. selenium python文档_selenium+python实现百度文库word文档抓取

    更新这个代码最近又改了一点,另外和其他一些小程序一起放在了一个jupyter notebook里,现在挂在github上面.github现在对jupyter notebook的支持非常的好,甚至可以直 ...

  4. 使用POI读取word文档

    使用POI 读取word 文档(word 2003和2007) 最近在给客户做系统的时候,用户提出需求,要能够导入 word 文件,现在 microsoft word 有好几个版本 97.2003.2 ...

  5. 使用poi操作word文档实现套打功能

    使用poi操作word文档实现套打功能 本文目的是为了分享一个实现套打功能,但是不同于简单的word的文本替换而是采用poi对word的文本框就行操作实现的功能: poi中各种jar的说明 套打的实现 ...

  6. POI生成word文档,图片显示为空白或不显示

    我想要用java,通过poi实现word文档中插入文字和图片来发送邮箱附件.但是发现在对word操作中,图片是白的,size如果设置小了直接没有图片.  经过百度 参考解决 Java poi 3.8 ...

  7. POI生成word文档,包括标题,段落,表格,统计图(非图片格式)

    Apache POI 是用Java编写的免费开源的跨平台的 Java API,Apache POI提供API给Java程式对Microsoft Office格式档案读和写的功能.POI为"P ...

  8. POI操作Word文档工具

    POI操作Word文档工具 1.POI简单介绍 2.POI操作Word文档基本方法 3.POI操作Word文档基本方法应用 4.POI操作Word文档工具类 1.POI简单介绍 POIFS(可疑混淆执 ...

  9. java利用POI替换word文档中的标签

    java利用POI替换word文档中的标签 <dependency><groupId>org.apache.poi</groupId><artifactId& ...

最新文章

  1. GRE词汇乱序版-夹生的词汇2
  2. 很好的一篇讲LTP在编解码中的作用的文章
  3. React Native之js调用Android原生使用Callback传递结果给js
  4. 雅士利牵手阿里云实现新零售改造,双11全渠道成交金额同比增长超过200%
  5. python matlablib安装踏坑记
  6. Java事件侦听器函数_SWT 计算器 按钮事件监听 获取按钮text值
  7. ios多线程之NSThread头文件详解
  8. [******] 树问题:普通二叉树的创建与遍历
  9. linux内核驱动ldd3_走进linux 驱动开发 之 内核模块
  10. Linux学习笔记---网线直连电脑和开发板使用nfs下载文件
  11. 主子表对应的字段_Power Pivot针对表筛选的函数及差异
  12. [工具] PicGo + Github 图床
  13. Basic开发笔记:Basic语言介绍、环境搭建、基本语法示例与程序实例
  14. Sublime Text2使用教程
  15. 常与同好争高下,不与傻瓜论短长
  16. 什么东西可以提高睡眠质量、这五款助眠好物助你摆脱困扰
  17. linux关机卡屏,Ubuntu关机卡住无法关机的解决方法
  18. 【九校3D2T3】世界第一的猛汉王
  19. 移动IM产品发展史及趋势预测
  20. 查找两个数储存在二进制中相同的个数

热门文章

  1. 高职计算机文化基础考试试题,计算机文化基础期末试题(高职)新.doc
  2. Centos7 忘记密码的情况下,修改root或其他用户密码
  3. 杨元喜院士:《北斗+与综合PNT体系》
  4. android 地图面积测量,Android开发自定义控件,实现Arcgis for Android测距、测面积功能...
  5. 免费的jpg转pdf软件
  6. AI英雄 | 八问机器学习泰斗Jordan教授:AI其实并不神奇
  7. 优迈系统服务器初始化,OTIS电梯资料-优迈系统ALMCB_3.3调试指导书
  8. 解释 RESTful API
  9. linux db2 数据源配置文件,为 DB2 UDB 系列配置数据源
  10. 文本情感分析-机器学习实验三