What does Apache POI stand for?
Apache POI stands For “Poor Obfuscation Implementation“. Apache POI is an API provided by Apache Software Foundation which is a collection of different java libraries.
What is Apache POI?
Apache POI is a popular API that allows programmers to create, modify, and display MS Office files using Java programs. It is an open-source library developed and distributed by Apache Software Foundation to design or modify Microsoft Office files using Java programs.
Know more about Apache POI.
Is Apache POI free to use?
The POI project is OpenSource and developed/distributed under the Apache Software License v2. Unlike some other licenses, the Apache license allows free open source development.
What are the commonly used components of Apache POI?
The following tables show the commonly used components of Apache POI and their basic description:
|POIFS (Poor Obfuscation Implementation File System)||It is the oldest component of Apache POI. It is a pure Java implementation of the OLE 2 Compound Document Format.|
|HSSF (Horrible SpreadSheet Format)||It is used to read and write MS-Excel 97 (-2003) file format (.xls)|
|XSSF (XML SpreadSheet Format)||It is used to read and write MS-Excel XML (2007+) file format (.xlsx)|
|HSLF (Horrible Slide Layout Format)||It is used to read and write MS-PowerPoint 97 (-2003) file format (.ppt)|
|XSLF (XML Slide Layout Format)||It is used to read and write MS-PowerPoint (2007+) file format (.pptx)|
|HWPF (Horrible Word Processor Format)||It is used to read and write MS-Word 97 (-2003) file format (.doc)|
|XWPF (XML Word Processor Format)||It is used to read and write MS-Word (2007+) file format (.docx)|
|Common SS||It is a common Java API to read and write both MS-Excel files format .xls and .xlsx|
|Common SL||It is also a common Java API to read and write both MS-PowerPoint files format .ppt and .pptx|
Know more about Apache POI – Components
What are the features of the Apache POI?
Apache POI Features
- Apache POI provides stream-based processing which is useful for large files and takes less memory.
- Apache POI provides the freatures to create, read and write Microsoft document files (Excel, PowerPoint, Word).
- It is helpful to handle both XLS and XLSX formats of spreadsheets.
- It also provides SXSSF that is an extension of XSSF to work with very large excel sheets.
How do I install Apache POI?
There are two ways for installing Apache POI in Eclipse, based on your project type:
- Maven Project
- Stand alone Java Project
See the article here Apache POI – How to Install?
What are HSSF and XSSF?
HSSF and XSSF are the popular components of the Apache POI library. HSSF is the POI Project’s pure Java implementation of the Excel 97(-2007) (.xls) file format. XSSF is the POI Project’s pure Java implementation of the Excel 2007 OOXML (.xlsx) file format.
What does HSSF stand for?
The HSSF stands for “Horrible Spreadsheet Format“. It is one of the components of Apache POI used for reading and writing the Microsoft Excel (.XLS) file formats.
What does XSSF stand for?
The XSSF stands for “XML Spreadsheet Format“. It is a component of Apache POI used for reading and writing the Microsoft Excel (.XLSX) file formats.
What is XSSF in Java?
XSSF is prefixed before the class name to indicate operations related to a Microsoft Excel 2007 file or later. XSSFWorkbook and HSSFWorkbook are classes that act as an Excel Workbook. HSSFSheet and XSSFSheet are classes that act as an Excel Worksheet.
What is the difference between an XLS and XLSX file?
An XLS and XLSX are two different file extensions of Microsoft Excel. The main difference between XLS and XLSX is that XLS files use a Binary format whereas, XLSX uses a newer file format known as Open XML. The XLS extension is used by Microsoft Excel 2003 and earlier whereas the XLSX extension is used by Microsoft Excel 2007 and later.
How does Apache POI read data from Excel?
Steps to read excel files using Apache POI:
- Create a workbook bypassing the InputStream. eg.
HSSFWorkbook workbook = new
- Getting a sheet from the workbook. eg.
HSSFSheet sheet = workbook.getSheetAt(0);
- Iterate each Row of the sheet. eg.
Iterator<Row> iterator = sheet.iterator();
- Iterate each Cell of a Row. eg.
Iterator<Cell> cellIterator = row.cellIterator();
- Read the Cell value based on CellType.
- Repeat steps 3-5 to read more available data in a sheet.
See the complete implementation here: How to read Excel files in java using Apache POI?
How do I write data using Apache POI in Excel?
Steps to writing data in Excel files using Apache POI:
- Create a blank workbook. eg.
XSSFWorkbook workbook = new XSSFWorkbook();
- Create a sheet and name it. eg.
XSSFSheet spreadsheet = workbook.createSheet("Employee Data");
- Create a row. eg.
Row row = sheet.createRow(rownum++);
- Add cells to the sheet.
- Repeat Steps 3 and 4 to write the complete data.
See the complete implementation here: How to write Excel files in java using Apache POI?