Apache POI for Microsoft Office
POI简介
Apache POI是纯Java代码,用于支持对Microsoft Office文档的读写。POI为“Poor Obfuscation Implementation”的首字母缩写,意为“可怜的模糊实现”。
POI 分别支持各种符合Office Open XML(OOXML)标准和微软的OLE 2复合文档格式(OLE2)的读写操作。OLE2是早期MS的定义的格式(如.xls,doc,ppt)。OOXML是国际标准(如.xlsx,docx,pptx)。因此会有两个版本类实现来支持。下面是各MS文档对应的api组件包
文档 | 组件包 | 备注 |
---|---|---|
Excel | HSSF+XSSF+SXSSF | H:Horrible(讨厌的),X:(XML),SSF: SpreadSheet Format(电子表格) |
PowerPoint | HSLF+XSLF | |
Word | HWPF+XWPF | |
Outlook | HSMF | |
Visio | HDGF+XDGF | |
Publisher | HPBF |
组件包
Component | Application type | Maven artifactId | Notes |
---|---|---|---|
POIFS | OLE2 Filesystem | poi | Required to work with OLE2 / POIFS based files |
HPSF | OLE2 Property Sets | poi | |
HSSF | Excel XLS | poi | For HSSF only, if common SS is needed see below |
HSLF | PowerPoint PPT | poi-scratchpad | |
HWPF | Word DOC | poi-scratchpad | |
HDGF | Visio VSD | poi-scratchpad | |
HPBF | Publisher PUB | poi-scratchpad | |
HSMF | Outlook MSG | poi-scratchpad | |
DDF | Escher common drawings | poi | |
HWMF | WMF drawings | poi-scratchpad | |
OpenXML4J | OOXML | poi-ooxml plus either poi-ooxml-schemas or ooxml-schemas and ooxml-security | See notes below for differences between these options |
XSSF | Excel XLSX | poi-ooxml | |
XSLF | PowerPoint PPTX | poi-ooxml | |
XWPF | Word DOCX | poi-ooxml | |
XDGF | Visio VSDX | poi-ooxml | |
Common SL | PowerPoint PPT and PPTX | poi-scratchpad and poi-ooxml | SL code is in the core POI jar, but implementations are in poi-scratchpad and poi-ooxml. |
Common SS | Excel XLS and XLSX | poi-ooxml | WorkbookFactory and friends all require poi-ooxml, not just core poi |
组件依赖
Maven artifactId | Prerequisites | JAR |
---|---|---|
poi | commons-logging, commons-codec, commons-collections (since POI 3.15 beta 3), commons-math (since POI 4.0.0), log4j | poi-version-yyyymmdd.jar |
poi-scratchpad | poi | poi-scratchpad-version-yyyymmdd.jar |
poi-ooxml | poi, poi-ooxml-schemas | poi-ooxml-version-yyyymmdd.jar |
poi-ooxml-schemas | xmlbeans | poi-ooxml-schemas-version-yyyymmdd.jar |
poi-examples | poi, poi-scratchpad, poi-ooxml | poi-examples-version-yyyymmdd.jar |
ooxml-schemas | xmlbeans | ooxml-schemas-1.3.jar |
ooxml-security | xmlbeans For signing: bcpkix-jdk15on, bcprov-jdk15on, xmlsec, slf4j-api | ooxml-security-1.1.jar |
Excel组件包
(usermodel 需要较多的内存与CPU,若是手机端可能会因有内存不足异常)