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
15
votes
1 answer

Apache poi date format

Hi i am reading csv file and getting date in 01-01-2011 but i want it in 01-Jan-2011 format when i write .xlsx file using apache poi library. my code is XSSFDataFormat df =…
Lalit Chattar
  • 1,914
  • 8
  • 27
  • 49
15
votes
4 answers

Setting Excel cell value in Numeric format using POI

I want to store numeric data in excel sheet. The numeric data is represented by String type in my java code. Is it possible to set it as numeric without casting it? I've tried the following code, but it wasn't converted to numeric type (I get a…
omrid
  • 497
  • 3
  • 10
  • 20
15
votes
4 answers

Limitation while generating excel drop down list with Apache POI

I'm trying to generate an excel file with some validations, I've read the poi dev guides for implementing it. During implementation, I got an exception (String literals in formulas can't be bigger than 255 characters ASCII). POI concatenates all…
Jama A.
  • 15,680
  • 10
  • 55
  • 88
15
votes
3 answers

Copy Excel Sheet using Apache POI

How to copy one entire Excel sheet into another Excel sheet of the same workbook, using Java SE and Apache POI?
Shumon Saha
  • 1,415
  • 6
  • 16
  • 33
15
votes
1 answer

Apache POI-HSSF vs POI-XSSF

HSSF is the POI Project's pure Java implementation of the Excel '97(-2007) file format. XSSF is the POI Project's pure Java implementation of the Excel 2007 OOXML (.xlsx) file format. Are there any export limitations when using HSSF? I've once…
0x45
  • 779
  • 3
  • 7
  • 26
15
votes
6 answers

Invalid header signature; IOException with Apache POI on excel document

I'm getting: java.io.IOException: Invalid header signature; read 0x000201060000FFFE, expected 0xE11AB1A1E011CFD0 when trying to add some custom properties to an Excel document using apache POI HPSF. I'm completely sure the file is Excel OLE2…
Simeon
  • 7,582
  • 15
  • 64
  • 101
15
votes
7 answers

POI Auto Filter

How do I use Apache POI to pre-define an auto-filter region in an Excel 2007 document? A small code example or link would be nice.
David
  • 849
  • 5
  • 10
  • 16
15
votes
4 answers

How can I use predefined formats in DOCX with POI?

I'm creating a docx generator with POI and would like to use predefined formats. Word includes several formats like Title, Heading 1..10 etc. These formats are predefined in every DOCX you create with Word. I would like to use them in my docx…
guerda
  • 23,388
  • 27
  • 97
  • 146
15
votes
3 answers

Make the entire row bold using Apache POI

I am using Apache POI's HSSFWorkbook to write data to Excel spreadsheets. I want to make an entire row bold. Can someone please suggest how to do it?
rickygrimes
  • 2,637
  • 9
  • 46
  • 69
15
votes
3 answers

Create Excel Charts in Java

I've been using Apache POI to create and modify Excel spreadsheets, but I'm wondering if there is a way (even if it's with a different library, preferably open source) to create charts in Excel in the new xlsx format. It looks like POI has an…
Jeff Storey
  • 56,312
  • 72
  • 233
  • 406
15
votes
1 answer

How to know number of sheets in a workbook?

I'm using hssf api for reading data from xls files. But is there any way to get the exact no. of sheets in a workbook containing stored data?
Supereme
  • 2,379
  • 12
  • 46
  • 67
15
votes
5 answers

Set columnwidth of a table in XWPFTableCell (docx)

I'm generating a docx file with apache-poi. In the wordfile, I add tables, whose columns have a width I would like to see fixed. Currently, I use the technique described here:…
Yves V.
  • 775
  • 1
  • 7
  • 20
15
votes
3 answers

Get the cell value as how it was presented in excel

I am currently working on a project that reads an excel file using Apache POI. My task seems to be simple, I just need to get the cell value as it was display in the excel file. I am aware of performing a switch statement based on the cell type of a…
Bnrdo
  • 5,325
  • 3
  • 35
  • 63
15
votes
7 answers

Is there any way to read both .xls and .xlsx files using Apache POI?

I need to create a method that can read both xls and xlsx files. According to my research, HSSF is used to read xls and XSSF to read xlsx. Is there a part of the Apache POI I can use to read both files? I also came across the ss.usermodel but found…
TOMAS DEL CASTILLO
  • 167
  • 1
  • 1
  • 5
15
votes
3 answers

Access to the color palette in an XSSFWorkbook

When using POI, cells and fonts in excel documents contain color information which does not always return an rgb value and it often only offers an index value. The indexed value must be looked up against something to get a color. In an HSSFWorkbook…
Paul Gregoire
  • 9,715
  • 11
  • 67
  • 131