poi获取word批注
package test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream; import org.apache.poi.xwpf.model.XWPFCommentsDecorator;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
/**
* 获取word批注 poi3.14
* @author Administrator
*
*/
public class GetPiZhuFromWord {
private static XWPFDocument comments;
public static File getFile(String sampleFileName) {
File f = new File(sampleFileName);
return f;
}
public static InputStream openResourceAsStream(String sampleFileName) {
File f = getFile(sampleFileName);
try {
return new FileInputStream(f);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
} public static XWPFDocument openSampleDocument(String sampleName) throws IOException {
InputStream is = openResourceAsStream(sampleName);
return new XWPFDocument(is);
}
public static void set() throws IOException {
comments = openSampleDocument("C:\\WordWithAttachments.docx");
}
public static void main(String[] args) throws IOException{
set();
testComments();
}
public static void testComments() {
int numComments = 0;
for (XWPFParagraph p : comments.getParagraphs()) {
XWPFCommentsDecorator d = new XWPFCommentsDecorator(p, null);
if (d.getCommentText().length() > 0) {
numComments++;
System.out.println(d.getCommentText());
}
}
} }
poi获取word批注的更多相关文章
- C# 获取word批注信息
今天在Silverlight 应用程序中实现了 获取word文档批注信息 的功能. 在wcf服务继承接口类中编写的函数如下 /// <summary> /// 获取word批注信息 /// ...
- Java 获取Word批注所标记的文本和图片
[环境配置] 本文将通过Java程序代码来展示如何来获取Word批注所标注的文本和图片.这里使用的Word Jar包工具是Free Spire.Doc for Java,在pom.xml中按如下步骤配 ...
- poi操作word文档文件操作
import org.apache.poi.POITextExtractor; import org.apache.poi.hwpf.extractor.WordExtractor; //得到.doc ...
- 利用poi操作word文档
关键字:POI JAVA 批注 总页数 总字符数 一:认识POI Apache POI是一个开源的利用Java读写Excel.WORD等微软OLE2组件文档的项目.最新的3.5版本有很多改进,加入了对 ...
- Java POI 解析word文档
实现步骤: 1.poi实现word转html 2.模型化解析html 3.html转Map数组 Map数组(数组的操作处理不做说明) 1.导jar包. 2.代码实现 package com.web.o ...
- POI生成WORD文档
h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h ...
- POI读写Word docx文件
使用POI读写word docx文件 目录 1 读docx文件 1.1 通过XWPFWordExtractor读 1.2 通过XWPFDocument读 2 写docx ...
- Poi之Word文档结构介绍
1.poi之word文档结构介绍之正文段落 一个文档包含多个段落,一个段落包含多个Runs,一个Runs包含多个Run,Run是文档的最小单元 获取所有段落:List<XWPFParagraph ...
- poi 读取word文档
1.导入jar包 官网下载地址: https://www.apache.org/dyn/closer.lua/poi/release/bin/poi-bin-3.17-20170915.zip 最开始 ...
随机推荐
- vue之父子组件之间的通信方式
(一)props与$emit <!-这部分是一个关于父子组件之间参数传递的例子--> <!--父组件传递参数到子组件是props,子组件传递参数到父组件是用事件触发$emit--&g ...
- selenium第三课(selenium八种定位页面元素方法)
selenium webdriver进行元素定位时,通过seleniumAPI官方介绍,获取页面元素的方式一共有以下八种方式,现按照常用→不常用的顺序分别介绍一下. 官方api地址:https://s ...
- 编译android framework的例子【转】
本文转载自:http://blog.csdn.net/brucexu1978/article/details/7610358 在开发过程中,尤其是Framework相关开发时,有时候需要重新编译资源文 ...
- [POI2012]FES-Festival
https://www.zybuluo.com/ysner/note/1252538 题面 有一个数列\(\{a\}\).现给定多组限制,限制分成\(2\)类,第一类是\(a_x+1=a_y\),有\ ...
- sqlserver2005连接失败,不存在或拒绝访问
sqlserver2005连接失败,不存在或拒绝访问 启动tcp/ip连接的方法: 打开 /Microsoft SQL Server 2005/配置工具/目录下的SQL Server Configur ...
- Linux下 CentOS 7 对比6 改动详解 及 系统安装
系统基础服务变化 操作系统 本文CentOS7 为最新版7.5 本文CentOS6 为6.9 操作 Centos6 Centos7 对比 自动补全 只支持命令.文件名 支持命令.选项.文件名 文件系统 ...
- bzoj 3396: [Usaco2009 Jan]Total flow 水流【最大流】
最大流生动形象的板子,注意数组开大点 #include<iostream> #include<cstdio> #include<queue> #include< ...
- 10.11 NOIP模拟题(1)
/* 离散化 差分 */ #include<bits/stdc++.h> #define N 4000007 using namespace std; int n,ans; int tmp ...
- Windows 和 Linux 上Redis的安装守护进程配置
# Windows 和 Linux 上Redis的安装守护进程配置 Redis 简介 Redis是目前最常用的非关系型数据库(NOSql)之一,常以Key-Value的形式存储.Redis读写速度 ...
- PowerDesigner 的使用教程
PowerDesigner 的使用这两篇博客挺好,我也是跟着学习,就不再写了: 初步学习: http://www.cnblogs.com/huangcong/archive/2010/06/14/17 ...