Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Whether you have balance sheets, account information downloads, tax calculations, or pay slips, they all tend to come in Microsoft Excel. Non-IT professionals feel comfortable using Microsoft Excel as a data exchange technology. The Jakarta POI (Poor Obfuscation Implementation) API is a fantastic way for Java programmers to access Microsoft document formats. The most mature API from Jakarta POI is the HSSF (Horrible Spreadsheet Format) API, which accesses Microsoft Excel documents.
In this article, I walk you through the steps for creating and reading Excel documents, and for using fonts and cell styling—all using Java.
Note: You can download the source code for all the examples in this article from Resources.
The key terms associated with Jakarta POI are as follows:
The Jakarta POI API can be used to create an Excel document programmatically. The important steps involved are:
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Java Excels");
HSSFRow row = sheet.createRow((short)0);
HSSFCell cell = row.createCell((short) 0);
cell.setCellValue("Have a Cup of XL");
In this example, you'll see how to read values from an Excel document.
Let's assume this is our Excel sheet:
The key steps in reading the Excel sheet are as follows:
HSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(fileToBeRead));.
HSSFSheet sheet = workbook.getSheetAt(0);. A sheet can also be referred to by name. Let's assume that the Excel sheet has the default name "Sheet1". It can be referred to as follows:
HSSFSheet sheet = workbook.getSheet("Sheet1");.
HSSFRow row = sheet.getRow(0);.
HSSFCell cell = row.getCell((short)0);.
Now let's assume that we want to see the list of all declared methods and member variables in a jar file. It would be ideal to have a consolidated list of all information in one single file. We would like to view the information so that the class names are in the first column, declared fields in the second column, and declared methods in the third column, with the column headings appearing in red.
|Forum migration complete By Athen|
|Forum migration update By Athen|
|Protecting excel spreadsheet reads from bad data. By ddyer|
|Read Excel file with java application By Armel|
|Java class to write data to excel By Anonymous|
|embedding objects in excel sheet ` By akshayjain7983|
download By enigma
( 1 2 all )
|Cactus information By vidhyap|
|read file excel with graphic By antonella|
|jxcell By jxcell|
|Comments on Jakarta Apis for Excel. By Jean Pierre|
|How to get range coordinates By kvdg|
|Excelling in Excel with Java By bcappel|
|xml to xls By Anonymous|
|Sheet By Anonymous|
|Multiple Sheets By Joe P|
|How can only one heading constitute two columns? By Anonymous|
|How to hyperlink any label in excel sheet through By javadigaddi|
|how to read cell defined by name ? By Quan|
|Excellent Article... By AnandKumar|
|Useful for desktop apps By Martin Bromley|
|Does POI API support 'Data->Group & Outline' featu By Anonymous|