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
18
votes
9 answers

How to convert my xlsx sheet to java object using Apache POI

can any one suggest me to convert my xlsx sheet to java object using Apache POI. eq, my excel sheet contains two columns emp_no emp_name 01 anand 02 kumar and my java object Employee{ String empNo; String empName; } Now I want…
Anand
  • 339
  • 4
  • 5
  • 16
18
votes
1 answer

Apache POI insert image

I am having troubles with inserting a picture in an excel sheet im making. There are a lot of question about this subject, but I simply cannot figure out what am I doing wrong. My code runs, shows no errors but I do not see an image inserted :( here…
SteBra
  • 4,188
  • 6
  • 37
  • 68
18
votes
3 answers

Apache POI - How to protect sheet with options?

I'm using the Apache POI to generate an Excel File (2007). What I want is to protect the sheet, but with some options enabled. By options I mean the check box list when you try to protect the sheet in the Excel application (under the label "Allow…
John Bautista
  • 1,480
  • 3
  • 29
  • 60
18
votes
3 answers

How to read excel file omitting first two rows

I have an excel file of 111 rows. I need to omit first two rows of the sheet and then read the file using java and POI.
Priya
  • 469
  • 3
  • 6
  • 14
18
votes
2 answers

Java POI cannot find symbol WorkbookFactory

im doing a conversion of the HSSF model to XSSF. Im getting lil errors here and there. I donwloaded the latest POI and dropped all the jar files in and did the apache includes in my java class.....getting this error: import…
Doc Holiday
  • 9,928
  • 32
  • 98
  • 151
18
votes
6 answers

Close Filehandle for Workbook (apache poi)

I constructed a new Workbook using WorkbookFactory.create(new File("path/to/xlsx")). However, when I try to edit the File in Excel after starting the application, I get an error message that the file is in use. Do I have to free the file up, and if…
ted
  • 4,791
  • 5
  • 38
  • 84
17
votes
4 answers

Get columns' names in Excel file using Apache POI

How to get the column names in an Excel file using Apache POI, to make sure that the columns are ordered as expected.
Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498
17
votes
3 answers

Export to Excel JSF and PrimeFaces

Using JDK 1.6, JSF 2.1, PrimeFaces 2.2.1, POI 3.2, and Apache Tomcat 7 I am trying to setup a servlet to allow a download of an excel file based on the user selection. The excel document is created at runtime. No errors and the code does get into…
Berek Bryan
  • 13,755
  • 10
  • 32
  • 43
17
votes
2 answers

How to apply background color for the rows in excel sheet using Apache POI?

I am using Apache POI for exporting data into excel sheet. it works fine. the problem is i need apply yellow background color for few rows in the excel sheet while generating the excel sheet. please hellp me how to apply background color for the…
reddy
  • 701
  • 2
  • 10
  • 10
17
votes
1 answer

Apache POI DataFormatter Returns Scientific Notation

I have an xlsx file I'm reading with apache poi 3.17 in java 6. In one instance I have a cell with the value, 123456789011. This is read into java as a NUMERIC CellTypeEnum Cell. When I use DataFormatter to get the value of the cell like…
user3813942
  • 311
  • 1
  • 3
  • 13
17
votes
2 answers

How to get columns from Excel files using Apache POI?

In order to do some statistical analysis I need to extract values in a column of an Excel sheet. I have been using the Apache POI package to read from Excel files, and it works fine when one needs to iterate over rows. However I couldn't find…
posdef
  • 6,498
  • 11
  • 46
  • 94
17
votes
2 answers

Always show two decimal points in excel cells using Apache poi

For example, XSSFCellStyle style=(XSSFCellStyle)…
Tiny
  • 27,221
  • 105
  • 339
  • 599
17
votes
4 answers

How to get the last column index reading excel file?

How do i get the index of the last column when reading a xlsx file using the Apache POI API? There's a getLastRowNum method, but I can't find nothing related to the number of columns... EDIT: I'm dealing with XLSX files
marcosbeirigo
  • 11,098
  • 6
  • 39
  • 57
17
votes
8 answers

How to avoid java.lang.NoSuchMethodError: org.apache.poi.util.IOUtils.copy(Ljava/io/InputStream;Ljava/io/OutputStream;) in Apache POI

I have a code for adding watermark to existing .doc file. The following is the code I have tried so far public static void main(String[] args) { try { XWPFDocument xDoc = new XWPFDocument(new FileInputStream("test.doc")); …
Avinash Mishra
  • 1,346
  • 3
  • 21
  • 41
17
votes
6 answers

POI / Excel : applying formulas in a "relative" way

I'm using Apache's POI to manipulate Excel (.xls) files with Java. I'm trying to create a new cell whom content is the result of a formula as if the user had copied/pasted the formula (what i call the "relative" way, as opposite to "absolute"). To…
Nils
  • 401
  • 2
  • 6
  • 16