Download presentation
Presentation is loading. Please wait.
Published byDominic McKinney Modified over 8 years ago
1
CFUNITED – The premier ColdFusion conference www.cfunited.com Another Look at Microsoft Office Using Apache Jakarta POI Jeremy Lund June 28th, 2006
2
About Me Manager of the Web Resource Center University Health Care (Salt Lake City, Utah) Sun Certified Java Programmer for the Java 2 platform B.S., Computer Engineering from University of Utah
3
Goals What is POI? How do I install POI? What benefits do I get from using POI? What won't it do? POI alternatives Java tips Lots of code examples
4
What is POI?
5
What is Apache Jakarta POI? Poor Obfuscation Implementation A set of APIs for interacting with OLE 2 Compound Document Format files Examples: Word (.doc), Excel (.xls), and PowerPoint (.ppt)
6
Why Use POI? Data Import/Export
7
Why Use POI? Content Management
8
Why Use POI? Reporting
9
In an Ideal World...
10
In the Real World...
11
What other tools? Save as XML Save as HTML COM OpenOffice.org 2.0 POI is just one more tool
12
Anatomy of an OLE2CDF File
13
POIFS: At the Core POI file system (POIFS) is used to read and manipulate OLE2CDF files Package: org.apache.poi.poifs.filesystem Two types of stream entries supported: DirectoryEntry DocumentEntry
14
POIFS Examples Example: POIFSExample1.cfm Example: POIFSExample2.cfm
15
How Do I Get to the Data? APIs to interact with specific document types and streams XLS files (HSSF) 2.5.1 PPT files (HSLF) 3.0 alpha DOC files (HWPF) 2.5.1 scratchpad Document props (HPSF) 2.5.1 (read-only) 2.5.1 final ships with CF 7 I am using 3.0 alpha for this presentation
16
How to Install For 2.5.1 release: http://apache.cs.utah.edu/jakarta/poi/release/ For 3.0 alpha: http://apache.cs.utah.edu/jakarta/poi/dev/ Scratchpad is not included with CF 7 Stop CF services Save in {cfwebroot}/WEB-INF/lib Restart CF services
17
Quick Java-CF Review To use Java classes: createObject() – loads the class createObject(“java”,”fully.qualified.name”) Can use for static method calls obj.init() - creates an instance of the class using the specified constructor
18
Java Tip #1 Know your casting tools!
19
Java Tip #1 Casting tools javaCast(type,cfVar) boolean, int, long, float, double, string, null Null only available in 7 Primitive wrapper classes Array reflection classes java.lang.reflect.Array Call newInstance(class,int length)
20
Java Tip #2 Java reflection is your friend!
21
Java Tip #2 obj.getClass() gives you a reference to the class String value of name: obj.getClass().getName() Wrapper classes have a TYPE static variable to represent primitives.
22
org.apache.poi.hssf.usermodel Interface for reading and writing XLS files. Mature and reliable Basic class structure is similar to HTML table HSSFSheet = table HSSFRow = tr HSSFCell = td Example: HSSFExample1.cfm
23
Add some style to the spreadsheet HSSFCellStyle,HSSFFont Can modify: Fonts (size and style) Colors Background Fills Borders Widths and heights Example: HSSFExample2.cfm
24
Reading Spreadsheets Similar to writing spreadsheets Requires more care with datatypes! Null Example: HSSFExample3.cfm
25
org.apache.poi.hwpf Interface for reading and writing Word (DOC) files. In the scratchpad section of the library. Has worked for what I have used it for (reading files), which is all I will talk about today.
26
Structure of a Word Document
27
HWPF Example 1 Example: HWPFExample1.cfm
28
HWPF Example 2 More meaningful text Examples: HWPFExample2.cfm basicDocumentFacade.cfc
29
HWPF Example 3 Lists, Style Examples: HWPFExample3.cfm advancedDocumentFacade.cfc
30
org.apache.poi.org.apache.poi.hslf Interface for reading and writing PowerPoint (PPT) files. Early, but very active development
31
HSLF Example 1 Simple Slideshow parser Example: HSLFExample1.cfm
32
HSLF Example 2 Improved Slideshow parser XSLT Example: HSLFExample2.cfm slideShowExtractor.cfc
33
Limitations Available documentation Images Development activity
34
Resources http://jakarta.apache.org/poi/ http://jakarta.apache.org/poi/ http://www.wotsit.org/ http://www.wotsit.org/ google “jakarta poi”
35
Thank you Jeremy Lund Jeremy.R.Lund@gmail.com
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.