Read doc file in java using poi

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

package com.howto;

import java.io.FileInputStream;

import java.io.IOException;

import org.apache.poi.hwpf.HWPFDocument;

/*

* Here we will learn how to read a Doc file

*/

public class ReadDocFile {

public static void main(String args[]) throws IOException {

/*

* Create input stream of the doc file - Provide exact path of the doc

* file to read

*/

FileInputStream fistream = new FileInputStream(

"File_Path");

HWPFDocument document = new HWPFDocument(fistream);

System.out.println("Length of docment is :"

+ document.characterLength());

System.out.println(document.getText());

System.out.println(document.getDocumentText());

}

}

Here we will use POI open source project to read windows doc file. PoI Jar will be required that can be downloaded from apache website.

时间: 2024-10-22 03:42:33

Read doc file in java using poi的相关文章

How to Read, Write XLSX File in Java - Apach POI Example---reference

No matter how Microsoft is doing in comparison with Google, Microsoft Office is still the most used application in software world. Other alternatives like OpenOffice and LiberOffice have failed to take off to challenge MS Office. What this mean to a

Create Excel file in java using PoI

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 8

Apache POI – Reading and Writing Excel file in Java

来源于:https://www.mkyong.com/java/apache-poi-reading-and-writing-excel-file-in-java/ In this article, we will discuss about how to read and write an excel file using Apache POI 1. Basic definitions for Apache POI library This section briefly describe a

Read / Write Excel file in Java using Apache POI

Read / Write Excel file in Java using Apache POI 2014-04-18 BY DINESH LEAVE A COMMENT About a year or two ago I was working with finance team where they wanted to pull the credit card transactions for all the customer using various combinations. Ex –

Java 使用poi导入excel,结合xml文件进行数据验证的例子(增加了jar包)

ava 使用poi导入excel,结合xml文件进行数据验证的例子(增加了jar包) 假设现在要做一个通用的导入方法: 要求: 1.xml的只定义数据库表中的column字段,字段类型,是否非空等条件. 2.excel定义成模板,里面只填写了所需要的数据,有可能数据有问题. 3.在导入的时候就需要对每个excel单元格的数据进行验证. 4.验证完之后,若所有数据正确,那么批量保存.若有一点点错误,就不执行保存操作,并提示错误原因. 思路: 1.完美使用了Map的功能,先将xml中的数据存入map

Java使用POI实现数据导出excel报表

在上篇文章中,我们简单介绍了java读取word,excel和pdf文档内容 ,但在实际开发中,我们用到最多的是把数据库中数据导出excel报表形式.不仅仅简单的读取office中的数据.尤其是在生产管理或者财务系统中用的非常普遍,因为这些系统经常要做一些报表打印的工作.而数据导出的格式一般是EXCEL或者PDF .所以今天我们来简单看一下利用Apache  POI实现数据库中数据导出excel报表.在java中有很多实现数据导出excel报表的第三方jar包.但在比较了一下感觉还是POI相对来

java使用POI进行Excel读写

1 jar包下载 参考链接:http://www.cnblogs.com/gmq/archive/0001/01/01/1521496.html poi-3.7-20101029.jar和源码下载地址:http://pan.baidu.com/s/1sjNmnc5#path=%252F04technology%252F01J2EE%252Fjar 2 ExcelHelper类 package zjr.amy.excel; import java.io.BufferedInputStream; i

使用java Apache poi 根据word模板生成word报表

项目开发过程中,客户提出一堆导出报表的需求,需要导出word格式,页眉还需要加上客户公司的logo,试了几种方案,最后选择了用 Apache poi 加上自定义标签的方式实现. 目前功能还比较简单,一些复杂的表格做不了,但是已经基本满足项目需求了. 使用poi读取word模板,替换word中的{text}标签,并根据自定义标签循环生成表格或表格中的行. 代码示例下载:https://download.csdn.net/download/u012775558/10306308 注意,仅支持docx

java使用POI实现excel文件的读取,兼容后缀名xls和xlsx

需要用的jar包如下: 如果是maven管理的项目,添加依赖如下: <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.14</version> </depen