[JAVA]POI(Apache POI)各Jar包的作用

来源:互联网 发布:owncloud9 php 编辑:程序博客网 时间:2024/05/16 12:03

文章来源:http://blog.csdn.net/szwangdf/article/details/39053859

Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能。

 

目前POI的最新发布版本是3.10_FINAL.该版本保护的jar包有:

Maven artifactIdPrerequisitesJARpoicommons-logging, commons-codec, log4jpoi-version-yyyymmdd.jarpoi-scratchpadpoipoi-scratchpad-version-yyyymmdd.jarpoi-ooxmlpoi, poi-ooxml-schemaspoi-ooxml-version-yyyymmdd.jarpoi-ooxml-schemasxmlbeanspoi-ooxml-schemas-version-yyyymmdd.jarpoi-examplespoi, poi-scratchpad, poi-ooxmlpoi-examples-version-yyyymmdd.jarooxml-schemasxmlbeansooxml-schemas-1.1.jar


很多人都困惑POI那么多Jar到底应该导入哪一个。

实际上很多时候我们只利用POI来操作Excel。甚至只用xls这一种格式。

那么就没有必要全部都导入了。具体应该使用哪个JAR包请参考以下内容:

Component Map

The Apache POI distribution consists of support for many document file formats. This support is provided in several Jar files. Not all of the Jars are needed for every format. The following tables show the relationships between POI components, Maven repository tags, and the project's Jar files.

ComponentApplication typeMaven artifactIdNotesPOIFSOLE2 FilesystempoiRequired to work with OLE2 / POIFS based filesHPSFOLE2 Property Setspoi HSSFExcel XLSpoiFor HSSF only, if common SS is needed see belowHSLFPowerPoint PPTpoi-scratchpad HWPFWord DOCpoi-scratchpad HDGFVisio VSDpoi-scratchpad HPBFPublisher PUBpoi-scratchpad HSMFOutlook MSGpoi-scratchpad OpenXML4JOOXMLpoi-ooxml plus one of
poi-ooxml-schemas, ooxml-schemasOnly one schemas jar is needed, see below for differencesXSSFExcel XLSXpoi-ooxml XSLFPowerPoint PPTXpoi-ooxml XWPFWord DOCXpoi-ooxml Common SSExcel XLS and XLSXpoi-ooxmlWorkbookFactory and friends all require poi-ooxml, not just core poi

当我们只要使用xls格式时、只要导入poi-version-yyyymmdd.jar就可以了。

当我们还要使用xlsx格式、还要导入poi-ooxml-version-yyyymmdd.jar。

至于poi-ooxml-schemas-version-yyyymmdd.jar这个jar基本不太会用到的。

当我们需要操作word、ppt、viso、outlook等时需要用到poi-scratchpad-version-yyyymmdd.jar。

0 0