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
25
votes
3 answers

Using Apache POI - Zip Bomb detected

When I am trying to write data to an Excel sheet, using Apache POI which contains more than 64000 records, where SXSSF is used, I am getting the below error: Zip bomb detected! The file would exceed the max. ratio of compressed file size to the…
user3428736
  • 864
  • 2
  • 13
  • 33
25
votes
4 answers

How to get the Cell value of A1(Cell Address) using apache poi 3.6

I have Excel Cell Address like A1,A2. So, how to access this cell programatically using poi3.6 another way is row=mySheet.getRow(); cell=row.getCell(); But i have the address in the format of A1 ... so, how do I access those cell programatically
Saravanan
  • 11,372
  • 43
  • 143
  • 213
25
votes
2 answers

How to process old excel .xls files using POI?

I switched from jxl to poi since POI has more features. However, I wasn't able to process the xls files that were generated in the old format. Now I am getting this error: org.apache.poi.hssf.OldExcelFormatException: The supplied spreadsheet …
Wael
  • 1,533
  • 4
  • 20
  • 35
24
votes
6 answers

Copying Excel Worksheets in POI

Does anyone know of a means to copy a worksheet from one workbook to another using POI? The Workbook class has a cloneSheet method, but there doesn't seem to be able to insert a cloned sheet into a new workbook? If there isn't an API to do this…
Patrick Nichols
24
votes
2 answers

How to set fixed column width in Apache POI

How to set fixed column width in Apache POI. I want to make my first column to fixed width. I have tried with sheet.setColumnWidth(0, 1000); cellStyle.setWrapText(true); //Set wordwrap it is not reflecting public XSSFWorkbook…
Divagar Haldurai
  • 399
  • 2
  • 3
  • 11
24
votes
1 answer

HSSFWorkbook vs XSSFWorkbook vs SXSSFWorkbook - Apache-poi

HSSFWorkbook vs XSSFWorkbook and the advantages/disadvantages of XSSFWorkbook and SXSSFWorkbook?
Sedat Polat
  • 1,631
  • 2
  • 18
  • 28
24
votes
5 answers

Determine MS Excel file type with Apache POI

Is there a way to determine MS Office Excel file type in Apache POI? I need to know in what format is the Excel file: in Excel '97(-2007) (.xls) or Excel 2007 OOXML (.xlsx). I suppose I could do something like this: int type =…
Alexey Berezkin
  • 1,513
  • 1
  • 10
  • 18
24
votes
5 answers

AutosizeColumns on SXSSFWorkbook

Is it possible to autoSizeColumns on a streaming SXSSFWorkbook? I implemented an export functionality to export a list of objects to excel. At first I used the XSSFWorkbook (not streaming) and after all the cells were created, I autosized all the…
sterym
  • 543
  • 1
  • 3
  • 9
24
votes
8 answers

Add border to merged cells in excel Apache poi java.?

I'm using Apache POI and I need to put a border in a range of cells or merged region. I am merging the cells with three rows and five columns. But I am not able to add the border to it. So how do I do this?
ashu
  • 579
  • 2
  • 6
  • 17
23
votes
7 answers

When getting cell content using Apache-POI Library, I get both "Cannot get a numeric value from a text cell" and the reverse of that. How do I fix it?

I realize the question is a little confusing, but I didn't know how else to word it. Anyway, here is the original code: private void readFile(String excelFileName) throws FileNotFoundException, IOException { XSSFWorkbook workbook = new…
crstamps2
  • 606
  • 2
  • 6
  • 16
23
votes
6 answers

java.lang.OutOfMemoryError: Java heap space while reading excel with Apache POI

My file is 9MB and I got this error while loading workbook. XSSFWorkbook workbook = new XSSFWorkbook(excelFilePath); this line causes to java.lang.OutOfMemoryError: Java heap space How can I solve this?
user467871
23
votes
1 answer

Write number in excel cells using Apache POI

How can I write my full value in cell with help of poi ? i.e. if value is 1000.000 then how can I write this full value without truncating 000 after "." with POI? means I want full value. In my case, it only takes 1000 but this is not right format…
Ravi Parmar
  • 1,392
  • 5
  • 24
  • 46
23
votes
6 answers

Issues resolving XSSFWorkbook - Java - POI .jar

I'm trying to do work upgrading a Java application to handle .xlsx, using a newer POI library than our existing one. I'm having issues similar to those mentioned in the comments to the answer here: Apache POI, using both XSSF and HSSF I'm pointing…
Nick
  • 231
  • 1
  • 2
  • 3
23
votes
2 answers

How to set Author name to excel file using poi

I'm creating an excel (.xlsx) file using poi (java). After I create the excel file I see the excel file Author as "Apache POI". Is there any way to change that? Here is the code I'm using to create excel file... import…
user1430989
  • 525
  • 2
  • 6
  • 15
22
votes
6 answers

Using Excel templates with Apache POI

Basic question: How do I load an Excel template for use with POI and then save it to an XLS file? Edit: The answer is: FileInputStream inputStream = new FileInputStream(new File(templateFile)); Workbook workbook = new…
Jake
  • 15,007
  • 22
  • 70
  • 86