Beruflich Dokumente
Kultur Dokumente
Dustin Marx
http://marxsoftware.blogspot.com/ 13 February 2007 All photographs of
Denver provided by Denver Metro Convention & Visitors Bureau and used with permission.
13 February 2007
Trademarks
Several products, specifications, and other trademarked terms appear in this presentation and all trademarks remain the property of their respective trademark owners. Trademark owners include:
Microsoft Corporation (Excel and Office Products) Sun Microsystems (Java) Apache Software Foundation
Excel with Apache POI 13 February 2007
Agenda
Photograph of Maroon Bells (near Aspen) provided by Denver Metro Convention & Visitors Bureau and used with permission.
Apache POI (and POI-HSSF) Overview Creating an Excel Document with POI-HSSF Reading an Excel Document with POI-HSSF Key and Helper POI-HSSF Classes Apache POI Limitations and Gotchas Handling Open Office 2007 XML Formats Additional References and Resources
Excel with Apache POI 13 February 2007
Write scripts with JVM-based scripting languages (JRuby, Groovy, etc.) for reporting in Excel
Example: Database management using POI
Excel with Apache POI 13 February 2007
Formerly known as Jakarta POI Focus of this presentation is on reading and writing Excel with Apache POIs POI-HSSF
http://poi.apache.org/hssf/index.html
Excel with Apache POI 13 February 2007
Status
Most Complete And Thorough Early development phase Mostly read only; less complete Read only; less complete Read only; less complete
13 February 2007
HSSFCell
HSSFRow
HSSFSheet
Excel with Apache POI 13 February 2007
13 February 2007
13 February 2007
Instantiate a Workbook:
HSSFWorkbook workbook = new HSSFWorkbook();
2.
3.
4.
13 February 2007
OutputStream os = null; try { os = new FileOutputStream( <<someFilePathAndName>> ); workbook.write(os); // workbook is an HSSFWorkbook } catch (IOException ioEx) . . . Note that each created sheet (HSSFSheet, step 2), row (HSSFRow, step 3), and cell (HSSFCell, step 4) can be edited for appearance and other attributes.
13 February 2007
13 February 2007
2.
3.
13 February 2007
5.
6.
13 February 2007
13 February 2007
HSSFName
Range Naming
HSSFFont
HSSFRichTextString HSSFDateUtil
Excel and Java Date Manipulation
HSSFDataFormat
Excel with Apache POI
13 February 2007
Should be able to pre-create Excel spreadsheet with charts, macros, or pivot tables and then use POI to populate data values in those pre-generated sheets
Excel with Apache POI 13 February 2007
Underlying XML format makes Office files potentially more open and portable
Excel with Apache POI 13 February 2007
Unzip and manipulate underlying XML files directly using XML tools (such as XQuery!)
See my Introduction to XQuery presentation tomorrow at RMOUG Training Days 2008
2.
3.
Use framework like OpenXML4J (http://sourceforge.net/projects/openxml4j/) Convert to older Office format and manipulate with Apache POI
13 February 2007
jXLS
Generates rich XLS templates for POI to write data to http://jxls.sourceforge.net/
13 February 2007
13 February 2007
Generate External Tables from an Excel Spreadsheet Using Apache Jakarta POI
http://www.oracle.com/technology/pub/art icles/saternos_tables.html
Excel with Apache POI 13 February 2007
13 February 2007
http://www.javabeat.net/articles/2007/10/apachepoi-reading-excel-sheet-using-java/
13 February 2007
JRuby
http://wickedcoolthoughts.blogspot.com/2007/ 12/excel-poi-wrapper-in-jruby.html
13 February 2007
13 February 2007