Upload
volodymyr-ostapiv
View
222
Download
1
Embed Size (px)
DESCRIPTION
Short presentation about Apache POI basics for English classes (SoftServe University)
Citation preview
Apache
POI
the Java API for
Microsoft Documents
AGENDA
• What is Apache POI?
• How to use Apache POI?
• Demo
WHAT APACHE POI STANDS FOR?
Poor Obfuscation Implementation
Provides pure Java libraries for
reading and writing files in Microsoft
Office formats
APACHE POI CAPABILITIES
Component APIs
• Excel (SS=HSSF+XSSF)
• Word (HWPF+XWPF)
• PowerPoint (HSLF+XSLF)
• Outlook (HSMF)
• Visio (HDGF)
• Publisher (HPBF)
WHAT IS APACHE POI
• Java library, part of Jakarta Project
• Open Source
• Supports ©Microsoft ™® proprietary
document formats
WHERE IT IS?
• Download:
http://poi.apache.org/download.html
• Maven:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
HOW TO USE IT?
//Create workbookXSSFWorkbook workbook = new XSSFWorkbook();
//Create a blank sheetXSSFSheet sheet = workbook.createSheet("Employee Data");
//Prepare data to be written (Object[])Map<String, Object[]> data = new TreeMap<String, Object[]>();data.put("1", new Object[] {"ID", "NAME", "LASTNAME"});data.put("2", new Object[] {1, “Volodymyr", “Ostapiv"});
Let’s write some data into excel file…
HOW TO USE IT?
//Don’t forget to write the workbook
FileOutputStream out = new FileOutputStream(
new File(“test.xlsx"));
workbook.write(out);
//Iterate over data and write to sheetSet<String> keyset = data.keySet();int rownum = 0;for (String key : keyset){ Row row = sheet.createRow(rownum++);
Object [] objArr = data.get(key);int cellnum = 0;for (Object obj : objArr){ Cell cell = row.createCell(cellnum++);
cell.setCellValue((String)obj);}
}
HOW TO USE APACHE POI
• Downloadable JAR file
• Maven/Graddle support
• Usage example
SO BORING…
HOW ABOUT HAVING FUN?
WHERE ENGINEERING
BECOMES ART
http://poi-painter.akceptor-kindle.cloudbees.net/
WE DID IT!
• Apache POI is…
• Usage examples
• Artistic demo
FINALLY
Apache POI: use it not only for work,
but as well for art!
My article about Apache POI:
http://habrahabr.ru/post/180489/
Sources:
https://github.com/Akceptor/POIPainter
My article about Apache POI:
http://habrahabr.ru/post/180489/
Sources:
https://github.com/Akceptor/POIPainter