poi读取word转换html

poi读取word转换html

ID:1429534

大小:51.50 KB

页数:5页

时间:2017-11-11

poi读取word转换html_第1页
poi读取word转换html_第2页
poi读取word转换html_第3页
poi读取word转换html_第4页
poi读取word转换html_第5页
资源描述:

《poi读取word转换html》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、POI读取word转换html文章分类:Java编程apachePOI读取word文档的文档比较少,所以只有自己慢慢的摸索,这篇文章也属于比较基础入门的,主要是针对读取word中的图片,以及文字的各种样式,如有不好的地方,请各位多多指教! Java代码  1./** 2. *  3. */  4.package com.util;  5.  6.import java.io.BufferedWriter;  7.import java.io.File;  8.import java.io.FileInputStream;  9.import java.io.FileNot

2、FoundException;  10.import java.io.FileOutputStream;  11.import java.io.IOException;  12.import java.io.OutputStream;  13.import java.io.OutputStreamWriter;  14.  15.import org.apache.poi.hwpf.HWPFDocument;  16.import org.apache.poi.hwpf.model.PicturesTable;  17.import org.apache.poi.hwpf

3、.usermodel.CharacterRun;  18.import org.apache.poi.hwpf.usermodel.Picture;  19.import org.apache.poi.hwpf.usermodel.Range;  20.  21./** 22. *  23. * @author 张廷 下午10:36:40 24. *  25. */  26.public class WordToHtml {  27.  28.    /** 29.     * 回车符ASCII码 30.     */  31.    private static fin

4、al short ENTER_ASCII = 13;  32.  33.    /** 34.     * 空格符ASCII码 35.     */  36.    private static final short SPACE_ASCII = 32;  37.  38.    /** 1.     * 水平制表符ASCII码 2.     */  3.    private static final short TABULATION_ASCII = 9;  4.  5.    private String htmlText = "";  6.  7.    /** 8

5、.     * 读取每个文字样式 9.     *  10.     * @param fileName 11.     * @throws Exception 12.     */  13.    public void getWordAndStyle(String fileName) throws Exception {  14.  15.        FileInputStream in = new FileInputStream(new File(fileName));  16.  17.        HWPFDocument doc = new HWPFDo

6、cument(in);  18.  19.        // 取得文档中字符的总数  20.        int length = doc.characterLength();  21.  22.        // 创建图片容器  23.        PicturesTable pTable = doc.getPicturesTable();  24.  25.        htmlText = "" + doc.getSummaryInformation().getTitle() + "

7、dy>";  26.  27.        // 创建临时字符串,好加以判断一串字符是否存在相同格式  28.  29.        String tempString = "";  30.  31.        for (int i = 0; i < length - 1; i++) {  32.            // 整篇文章的字符通过一个个字符的来判断,range为得到文档的范围  33.            Range range = new Range(i, i + 1, doc);  34.  35.

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。