16
Apache POI the Java API for Microsoft Documents

Apache poi

Embed Size (px)

DESCRIPTION

Short presentation about Apache POI basics for English classes (SoftServe University)

Citation preview

Page 1: Apache poi

Apache

POI

the Java API for

Microsoft Documents

Page 2: Apache poi

AGENDA

• What is Apache POI?

• How to use Apache POI?

• Demo

Page 3: Apache poi

WHAT APACHE POI STANDS FOR?

Poor Obfuscation Implementation

Provides pure Java libraries for

reading and writing files in Microsoft

Office formats

Page 4: Apache poi

APACHE POI CAPABILITIES

Component APIs

• Excel (SS=HSSF+XSSF)

• Word (HWPF+XWPF)

• PowerPoint (HSLF+XSLF)

• Outlook (HSMF)

• Visio (HDGF)

• Publisher (HPBF)

Page 5: Apache poi

WHAT IS APACHE POI

• Java library, part of Jakarta Project

• Open Source

• Supports ©Microsoft ™® proprietary

document formats

Page 6: Apache poi

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>

Page 7: Apache poi

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…

Page 8: Apache poi

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);}

}

Page 9: Apache poi

HOW TO USE APACHE POI

• Downloadable JAR file

• Maven/Graddle support

• Usage example

Page 10: Apache poi

SO BORING…

Page 11: Apache poi

HOW ABOUT HAVING FUN?

Page 12: Apache poi

WHERE ENGINEERING

BECOMES ART

http://poi-painter.akceptor-kindle.cloudbees.net/

Page 13: Apache poi

WE DID IT!

• Apache POI is…

• Usage examples

• Artistic demo

Page 14: Apache poi

FINALLY

Apache POI: use it not only for work,

but as well for art!

Page 15: Apache poi

My article about Apache POI:

http://habrahabr.ru/post/180489/

Sources:

https://github.com/Akceptor/POIPainter

Page 16: Apache poi

My article about Apache POI:

http://habrahabr.ru/post/180489/

Sources:

https://github.com/Akceptor/POIPainter