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

Delete an excel sheet using Apache POI

I have to delete a sheet from the Excel file. Here's my code snippet : FileInputStream fileStream = new FileInputStream(destFile); POIFSFileSystem fsPoi = new POIFSFileSystem(fileStream); HSSFWorkbook workbook = new HSSFWorkbook(fsPoi); int index…
Venkat
  • 2,604
  • 6
  • 26
  • 36
17
votes
2 answers

apache poi cellIterator skips blank cells but not in first row

I am creating a java program to read an excel sheet and create a comma separated file. When I run my sample excel file, with blank columns, The first row works perfectly, but the rest of the rows skip the blank cells. I have read about the code…
user2047551
  • 183
  • 1
  • 1
  • 8
17
votes
1 answer

Insert a Row in Excel Using Java Apache POI

I am developing a desktop application related to Excel sheets. I have some problems inserting rows between two rows. Is there any possibility to do this in Java using Apache POI? Workbook wb3=WorkbookFactory.create(new…
kark
  • 4,763
  • 6
  • 30
  • 44
17
votes
3 answers

Get Cell by a Cell reference letter identifier with Apache POI

I am trying to get the Cell from the Row by a Cell reference and I have a problem. For example I have: row.getCell(CellReference.convertColStringToIndex("B")); That works fine if the Column index is 1, but if Column was deleted so the B Column…
user1759136
17
votes
3 answers

Apache POI, creating new cells overrides the row style

I'm using Apache POI to export data to a .xlsx file and I want to style some of the rows and cells contained in the file. I'm using XSSF since the file is going to be read in Excel 2007+. Basically, my problem is that I'm trying to set a row style…
Jumbala
  • 4,764
  • 9
  • 45
  • 65
17
votes
1 answer

How to copy a sheet between Excel workbooks in Java

How can I copy a sheet between two different workbooks in Apache poi? The method is missing referring this thread. There is not such a solution.
MemLeak
  • 4,456
  • 4
  • 45
  • 84
17
votes
2 answers

Excel Drop down list using Apache POI

I need to create a drop down list in excel file using Apache POI. and I am able to do that so But I am not able to make first item in drop down list as default Item. public class sd { /** * @param args * @throws IOException */ public static…
Vineet
  • 861
  • 2
  • 7
  • 6
16
votes
5 answers

How to set a cell format to Text

I am using Apache-POI 3.14. I have a need to lock-down a cell to a "Text" format. The data in my cell might be all digits, but it is still considered a string. When I write the cell, I do it like…
Steve H.
  • 6,912
  • 2
  • 30
  • 49
16
votes
6 answers

Create excel chart using Apache POI

I need to create excel sheet from my Java code which contains charts like Bar chart, Line Chart etc using the Apache POI library. Is it possible? I am not able to find any useful code example for the same. Is there any other alternative for this…
javdev
  • 794
  • 2
  • 10
  • 23
16
votes
2 answers

How to read from merged cells of Excel in Java using Apache POI?

I have a Excel file in .xlsx format. I have stored data by merging cells to form various columns. I am reading the Excel file via a Java web application and saving its data to a database (MySQL). But when I read from merged cells I get null values…
Saber
  • 167
  • 1
  • 2
  • 6
16
votes
3 answers

Difference between HSSFWorkbook and Workbook in apache POI

I was studying read/write of excel using apachePOI library, i found two types of solution, i.e., one achieved using using HSSFWorkbook and other one with Workbook. Now i have doubt why there is two solution to achieve single functionality. My…
Shetty's
  • 617
  • 4
  • 13
  • 20
16
votes
2 answers

Embed files into Excel using Apache POI

I am exporting data to Excel file using Apache POI. In one weird requirement, I need to embed one file in the Excel using this POI. I have the file, and can be taken into streams or as byte arrays. After googling for much time, I am in a doubt…
Anoop
  • 1,439
  • 5
  • 20
  • 37
16
votes
2 answers

Apache POI - get number as integer

Numbers all come back from Apache POI cell values as Double. When I do getCell(...).toString(), a number that appeared as "123" in Excel will convert to "123.0". How can I tell that the number should have displayed as an integer? Is there some…
wrschneider
  • 17,913
  • 16
  • 96
  • 176
16
votes
9 answers

API to write huge excel files using java

I am looking to write to an excel (.xls MS Excel 2003 format) file programatically using Java. The excel output files may contain ~200,000 rows which I plan to split over number of sheets (64k rows per sheet, due to the excel limit). I have tried…
Jaskirat
  • 1,114
  • 1
  • 8
  • 17
16
votes
1 answer

Set Date format using Apache POI

I want to set date in date format in an Excel file with Apache POI. The value will set in such a manner so that in Address Bar it will show as mm/dd/YYYY and in cell it will show as dd-mmm (numeric day and month abbreviation: 01-Jan).
sairajgemini
  • 353
  • 1
  • 3
  • 11