Questions tagged [apache-poi]

Apache POI is a Java library for reading and writing various Microsoft file formats, especially Office related ones. It supports OLE2 and OOXML based formats, such as XLS, XLSX, DOC, DOCX, PPT and PPTX as well as a few others.

The mission statement of the Apache POI project is

... to create and maintain Java APIs for manipulating various file formats based upon the Office Open XML standards (OOXML) and Microsoft's OLE 2 Compound Document format (OLE2). This includes Excel formats (.xls and .xlsx), Word (.doc and .docx), PowerPoint (.ppt and .pptx), as well as others to a lesser extent like Visio, Outlook and Publisher.

This tag should be used for questions around using and extending Apache POI. Questions on the .Net port should use the tag instead.

More information on Apache POI, the bug tracker and download links are available from https://poi.apache.org/

If you are starting with Apache POI, you may find the Busy Developer's link very useful : https://poi.apache.org/spreadsheet/quick-guide.html

Apache POI releases are available under the Apache License, Version 2.0.

9727 questions
12
votes
4 answers

Learning Apache POI for Java

I'm trying to learn Apache POI for Java quickly (for manipulating Excel). I've been googling for tutorials, but so far all I've found is short, 2-paragraph explanations followed by a code sample. I wanted to find something a bit more comprehensive,…
froadie
  • 79,995
  • 75
  • 166
  • 235
12
votes
2 answers

How to set page orientation for Word document?

I use Apache POI XWPF to create and handle MS Word documents. But I didn't find in the documentation how to change the page orientation. Apparently this way should make it: XWPFDocument doc = new XWPFDocument(); CTDocument1 document =…
kapandron
  • 3,546
  • 2
  • 25
  • 38
12
votes
3 answers

NullpointerException when trying to read XLSX file

I currently have this code to open an xlsx file using apache POI File existingXlsx = new File("/app/app.xlsx"); System.out.println("File Exists: " + existingXlsx.exists()); Workbook workbook = WorkbookFactory.create(existingXlsx); When I try to…
Thizzer
  • 16,153
  • 28
  • 98
  • 139
12
votes
7 answers

Excel sheet POI validation: Out Of Memory Error

I am trying to validate an Excel file using Java before dumping it to database. Here is my code snippet which causes error. try { fis = new FileInputStream(file); wb = new XSSFWorkbook(fis); XSSFSheet sh = wb.getSheet("Sheet1"); …
Abhishek Singh
  • 10,243
  • 22
  • 74
  • 108
12
votes
6 answers

Convert csv to xls/xlsx using Apache poi?

I need to convert csv to xls/xlsx in my project? How can i do that? Can anyone post me some examples? I want to do it with Apache poi. I also need to create a cell from java side.
v0ld3m0rt
  • 866
  • 3
  • 12
  • 47
12
votes
3 answers

Excel Formula Not Updating Cell

I am using apache POI to change cells in an excel sheet. After I change the values, the cells with formulas corresponding to cells that have been changed are not updating. When I go into excel and click on the cell with the formula, and then click…
PandaBearSoup
  • 699
  • 3
  • 9
  • 20
12
votes
2 answers

How can I add the Apache POI Library in Eclipse - for Selenium Webdriver project?

I need to add the apache poi to my project (I need hssf, ss and xssf). I downloaded a jar file from the internet but it does not contain xssf. I went to http://poi.apache.org/ and I downloaded this:…
Maria
  • 121
  • 1
  • 1
  • 3
12
votes
2 answers

Insert a line break inside a paragraph in XWPFDocument

I am writing values into a word template using apache poi 3.8. I replace specific strings in a word file (keys) with required values, e.g. word document has a paragraph containing key %Entry1%, and I want to replace it with "Entry text line1 \nnew…
Vladimir Beletskiy
  • 308
  • 2
  • 3
  • 10
12
votes
3 answers

JAVA+POI API Excel- Need to increase width of the column

I want to increase the width of the column of excel sheet. as the i am writing trough code is long. and I need to drag the column manually to see the full text. I did this – HSSFRow dataRow = sampleDataSheet.createRow(0); HSSFCellStyle cellStyle =…
smriti
  • 1,124
  • 5
  • 14
  • 35
11
votes
3 answers

Write Double value in numeric cell with specific format in Apache Poi 3.7

I need to write a Double value in a numeric cell using a specific format, i mean, the generated xls must have numeric cells containing Double values like, for example: 8,1. I am trying something like: DecimalFormat dFormat = new…
Dani
  • 3,744
  • 4
  • 27
  • 35
11
votes
4 answers

How To Set Excel Default Row Height in Apache POI

I'm using Apache POI 3.7 with Spring MVC 3.1. How to set excel default row height in apache POI? I've tried sheet.setDefaultRowHeight((short) 100) and sheet.setDefaultRowHeightInPoints(100) but that doesn't work. Any suggestion for this…
Fitrah M
  • 983
  • 3
  • 17
  • 31
11
votes
3 answers

Make column read-only using apache poi

I am using apache-poi for generating the excel file. I need to make the 4th column read-only and the remaining 2 columns will be editable by the user. I am using XSSFCellStyle to achieve this but it's not working for me. The entire code…
simbu94
  • 1,012
  • 2
  • 10
  • 22
11
votes
1 answer

Convert Word to HTML with Apache POI

I see that there is a converter called WordToHtmlConverter but the process method is not exposed. How should I pass a doc file and get HTML file (or OutputStream)?
Ron
  • 393
  • 1
  • 4
  • 13
11
votes
1 answer

SXSSF: to where does it flush rows not in the window prior to output to file?

According to the SXSSF (Streaming Usermodel API) documentation: SXSSF (package: org.apache.poi.xssf.streaming) is an API-compatible streaming extension of XSSF to be used when very large spreadsheets have to be produced, and heap space is limited.…
John B
  • 32,493
  • 6
  • 77
  • 98
11
votes
4 answers

apache POI java.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/zip/ZipFile

I try to make word document using Apache POI 4.0.0, but i get error Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/zip/ZipFile at …
JuNas
  • 432
  • 2
  • 7
  • 16