Microsoft Office Programing With POI
Apache POI, a project run by the Apache Software Foundation, and previously
a sub-project of the Jakarta Project, provides pure Java libraries for reading
and writing files in Microsoft Office formats, such as Word, PowerPoint and Excel.
The name POI stands for Poor Obfuscation Implementation,
referring to the fact that the file formats seemed to be deliberately
obfuscated, but poorly, since they were successfully reverse-engineered. This expansion
– and those of the similar names for the various sub-projects – were removed from the
official web-pages in order to better market the tools to businesses who would not
consider such humour appropriate.
The POI consists of APIs for manipulating various file formats based upon
Microsoft's OLE 2 Compound Document Format using pure Java. Almost all Microsoft
Office files like Microsoft Excel, Microsoft Word, Microsoft Power Point, Microsoft
Visio Documents etc follows the OLE 2 Compound Document Format. But the new Office
2007 formats like .xlsx, .docx, .pptx etc are not based on the OLE 2 Compound Document Format
hense POI doesn't have the capability to read or write these types of documents. But work is
in progress to accomodate these types of documents. POI has the following components to read and write
the Microsoft's OLE 2 Compound Document Format based files.
POIFS (Poor Obfuscation Implementation File System) – This component reads and writes Microsoft's
OLE 2 Compound document format. Since all Microsoft Office files are OLE 2 files, this component is
the basic building block of all the other POI elements. POIFS can therefore be used to read a wider
variety of files, beyond those whose explicit decoders are already written in POI.
We can think of POIFS as a "zip" library. Once we get the data in a zip file we still need to interpret
the data. As a general rule, while all of our formats use POIFS, most of them attempt to abstract you from it.
HSSF (Horrible SpreadSheet Format) – reads and writes Microsoft Excel (XLS) format files. It can read
files written by Excel 97 onwards; this file format is known as the BIFF 8 format. As the Excel file
format is complex and contains a number of tricky characteristics, some of the more advanced features
cannot be read.
XSSF (XML SpreadSheet Format) – reads and writes Microsoft Excel OOXML (XLSX) format files – 3.5
branch only. Similar feature set to HSSF, but for Office Open XML files.
HPSF (Horrible Property Set Format) – reads "Document Summary" information from Microsoft Office
files. This is essentially the information that one can see by using the File|Properties menu item within
an Office application.
HWPF (Horrible Word Processor Format) – aims to read and write Microsoft Word 97 (DOC) format files.
HSLF (Horrible Slide Layout Format) – is a pure Java implementation for Microsoft PowerPoint files.
This provides the ability to read, create and edit presentations
HDGF (Horrible DiaGram Format) – is an initial pure Java implementation for Microsoft Visio binary
files. It provides an ability to read the low level contents of the files.