Apache Poi Recipes
-
Upload
paolo-mottadelli -
Category
Technology
-
view
6.025 -
download
1
description
Transcript of Apache Poi Recipes
![Page 1: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/1.jpg)
Apache POIRecipesPaolo Mottadelli - ApacheCon Oakland 2009
http://chromasia.comThursday, November 5, 2009
![Page 2: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/2.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
my to-do list
Thursday, November 5, 2009
![Page 3: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/3.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
POI @ Content Tech
✴ Document to application (and back)✴ Publish data
✴ Build a doc from your content
✴ Know your documents✴ Extract text
✴ Extract content
Thursday, November 5, 2009
![Page 4: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/4.jpg)
1A-B-C
Thursday, November 5, 2009
![Page 5: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/5.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
POI modules (1): OLE2
✴ POIFS: reading/writing Office Documents
✴ HSSF r/w Excel Spreadsheets
✴ HWPF r/w Word Docs
✴ HSLF r/w PowerPoint Docs
✴ HPSF r/w property sets
Thursday, November 5, 2009
![Page 6: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/6.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
POI modules (2): OOXML
✴ XSSF: r/w OXML Excel
✴ XWPF: r/w OXML Word
✴ XSLF: r/w OXML PowerPoint
Thursday, November 5, 2009
![Page 8: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/8.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
OOXML dev status
✴ XSSF: Final in POI-3.5
✴ XWPF: Draft (basic features)
✴ XSLF: Not covered (only text ext.)
Thursday, November 5, 2009
![Page 9: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/9.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
HSSF & XSSF
✴ Common user model interface
✴ User model based on existing HSSF
✴ Using OpenXML4J and SAX
Thursday, November 5, 2009
![Page 10: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/10.jpg)
2Same recipe, different flavours
Thursday, November 5, 2009
![Page 11: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/11.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Common H/XSSF access
✴ org.apache.poi.ss.usermodel
Thursday, November 5, 2009
![Page 12: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/12.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Upgrading to POI-3.5
✴ HSSFFormulaEvaluator.CellValue✴ convert from .hssf. to .ss.
✴ HSSFRow.MissingCellPolicy✴ convert from .hssf. to .ss.
✴ RecordFormatException in DDF✴ convert from .hssf. to .util. Dreadful Drawing Format
Thursday, November 5, 2009
![Page 13: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/13.jpg)
3MeetOffice Open XML
Thursday, November 5, 2009
![Page 14: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/14.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Open XML
✴ XML based✴ WordprocessingML
✴ SpreadsheetML
✴ PresentationML
✴ Stored as a package✴ Open Packaging Conventions
made (very) simple
Thursday, November 5, 2009
![Page 15: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/15.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Package concepts
✴ Package (the container)
✴ Part (xml file)
✴ Relationship✴ package-relationship
✴ part-relationship
Thursday, November 5, 2009
![Page 16: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/16.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Expanded package, Excel
Thursday, November 5, 2009
![Page 17: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/17.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
WordprocessingML
✴ body✴ paragraphs
✴ runs
✴ properties (for runs and pars)
✴ styles
✴ headers/footers ...
Thursday, November 5, 2009
![Page 18: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/18.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
SpreadsheetML
✴ workbook✴ worksheets
✴ rows
✴ cells
✴ styles
✴ formulas
✴ images ...
Thursday, November 5, 2009
![Page 19: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/19.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
PresentationML
✴ presentation✴ slides
✴ slides-masters
✴ notes-masters
✴ layout, animation, audio, video, transitions ...
Thursday, November 5, 2009
![Page 20: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/20.jpg)
4openxml4j
Thursday, November 5, 2009
![Page 21: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/21.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
openXML4J
✴ Package, parts, rels
"/xl/worksheets/sheet1.xml"
Thursday, November 5, 2009
![Page 22: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/22.jpg)
5Text Extraction
Thursday, November 5, 2009
![Page 23: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/23.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Extractors
✴ POITextExtractor✴ POIOLE2TextExtractor
✴ POIXMLTextExtractor
✴ XSSFExcelExtractor
✴ XWPFWordExtractor
✴ XSLFPowerPointExtractor
✴ If text is all what you need
getText()
Thursday, November 5, 2009
![Page 24: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/24.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Text extraction
✴ made simple
Thursday, November 5, 2009
![Page 25: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/25.jpg)
6EXCELSimple Tasks
Thursday, November 5, 2009
![Page 26: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/26.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
New Workbook
Thursday, November 5, 2009
![Page 27: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/27.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
New Sheet
Thursday, November 5, 2009
![Page 28: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/28.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Creating Cells
Thursday, November 5, 2009
![Page 29: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/29.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Cell types
Thursday, November 5, 2009
![Page 30: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/30.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Fills and colors
Thursday, November 5, 2009
![Page 31: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/31.jpg)
7EXCELImp/Exp to XML
Thursday, November 5, 2009
![Page 32: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/32.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Export to XML
Thursday, November 5, 2009
![Page 33: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/33.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
xmlMaps.xml
Thursday, November 5, 2009
![Page 34: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/34.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
XML Import/Export
Thursday, November 5, 2009
![Page 35: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/35.jpg)
8WORDSimple Doc
Thursday, November 5, 2009
![Page 36: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/36.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
A simple doc
Thursday, November 5, 2009
![Page 37: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/37.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Thursday, November 5, 2009
![Page 38: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/38.jpg)
9Use Case 1Alfresco Search
Thursday, November 5, 2009
![Page 39: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/39.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Use Case
✴ Upload a document
✴ Detect document mimetype
✴ Extract text and metadata
✴ Create search index
✴ Search (and find) the document
Thursday, November 5, 2009
![Page 40: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/40.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Without Tika✴ Detect the document mimetype
✴ (source/target mimetype)
✴ Get the proper ContentTransformer✴ (ContentTransformerRegistry)
✴ Tranform Doc Content to Text✴ (PoiHssfContentTransformer)
✴ Create Lucene indexPOI here
Thursday, November 5, 2009
![Page 41: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/41.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
With Tika
Thursday, November 5, 2009
![Page 42: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/42.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Extension use case
✴ Adding support for Office Open XML documents (Office 2007+)✴ Word 2007+
✴ Excel 2007+
✴ PowerPoint 2007+
Thursday, November 5, 2009
![Page 43: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/43.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
POI text extractors
✴ Remember?
Thursday, November 5, 2009
![Page 44: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/44.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Apache Tika (Excel)
Thursday, November 5, 2009
![Page 45: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/45.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Apache Tika
Thursday, November 5, 2009
![Page 46: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/46.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Apache Tika (Word)
Thursday, November 5, 2009
![Page 47: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/47.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Apache Tika (Word)
Thursday, November 5, 2009
![Page 48: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/48.jpg)
10Use Case 2JM LaffertyFinancial Forecasting
Thursday, November 5, 2009
![Page 49: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/49.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Make your wb look pro-
✴ Rich text
✴ Graphics
✴ Formulas & Named Ranges
✴ Data validations
✴ Conditional formatting
✴ Cell comments
Thursday, November 5, 2009
![Page 50: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/50.jpg)
Thursday, November 5, 2009
![Page 51: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/51.jpg)
Thursday, November 5, 2009
![Page 52: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/52.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Formula evaluation
✴ The evaluation engine enables you to calculate formula results from within a POI application
✴ Formulas may be added to your workbook by POI
✴ Evaluation is available for .xls and .xlsx
Thursday, November 5, 2009
![Page 53: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/53.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Formula evaluation (continued)
✴ All arithmetic operators are implemented
✴ Over 280 Excel built in functions are supported
Thursday, November 5, 2009
![Page 54: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/54.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Formula evaluation (code)
Thursday, November 5, 2009
![Page 55: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/55.jpg)
11Use Case 3:CQ5 Import
Thursday, November 5, 2009
![Page 56: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/56.jpg)
Thursday, November 5, 2009
![Page 57: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/57.jpg)
Thursday, November 5, 2009
![Page 58: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/58.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
importDocument()
Thursday, November 5, 2009
![Page 59: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/59.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
getParagraphs(...)
✴ Makes use of✴ org.apache.poi.hwpf.usermodel.Range
Thursday, November 5, 2009
![Page 60: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/60.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
importDocument()
Thursday, November 5, 2009
![Page 61: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/61.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
getTitle(...)
✴ Gets the first paragraph’s text
Thursday, November 5, 2009
![Page 62: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/62.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
importDocument()
Thursday, November 5, 2009
![Page 63: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/63.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Thursday, November 5, 2009
![Page 64: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/64.jpg)
Thursday, November 5, 2009
![Page 65: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/65.jpg)
Thursday, November 5, 2009
![Page 66: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/66.jpg)
12Want more?
Thursday, November 5, 2009
![Page 67: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/67.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
More Examples
✴ http://poi.apache.org/spreadsheet/examples.html
Thursday, November 5, 2009
![Page 68: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/68.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
Even more
✴ Get in touch✴ http://poi.apache.org/
✴ Get informed✴ [email protected]
✴ Get involved✴ http://svn.apache.org/repos/asf/poi/trunk/
Thursday, November 5, 2009
![Page 69: Apache Poi Recipes](https://reader034.fdocuments.in/reader034/viewer/2022052410/554c8001b4c905203f8b4b41/html5/thumbnails/69.jpg)
- ApacheCon US 2009, Oakland - Apache POI Recipes -
✴ Get slides✴ http://www.slideshare.net/paolomoz/apache-poi-recipes
Thanks
Thursday, November 5, 2009