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
10
votes
5 answers

File Excel From Apache POI Cant Open by Ms Excel (corrupt)

I don't know why the file I write using POI cant be opened by Ms Excel 2013, but the file is still readable by POI. (cell value can be changed) this is the error from file here is the code FileInputStream fis = null; try { fis = new…
ketelagoreng
  • 109
  • 1
  • 1
  • 7
10
votes
2 answers

how to set page margins for word document using apache poi?

I want to set page-margins for word document created using apache poi-3.9. I found it can be done using CTPageMar but CTPageMar is not being resolved. I am using apache poi-3.9 I tried this CTSectPr sectPr =…
imdzeeshan
  • 1,098
  • 20
  • 26
10
votes
2 answers

apache poi finding number of rows in a sheet

I have been using these methods to count the number of rows in a sheet getLastRowNum() and getPhysicalNumberOfRows() They are working fine on two sheets of my workbook. But the third sheet containing 5 rows is returning 1 extra with both of the…
tanvi
  • 927
  • 5
  • 17
  • 32
10
votes
3 answers

How to format the text in a XWPFTable in Apache POI

I have created a XWPFTable in word using Apache POI. Now the table is coming out properly with text in the column. Now I want to format the text in the table along with size, font etc. How can I do that? What I am seeing is that every trick is…
lucifer
  • 2,297
  • 18
  • 58
  • 100
10
votes
3 answers

Apache POI Width calculations

I'm having problems getting the exact size I want with my calculations for columnWidth and my calculated row height because I don't understand the documentation. In terms of columnWidth, I am using the line of code sheet.setColumnWidth(int…
Jon Rubins
  • 4,323
  • 9
  • 32
  • 51
10
votes
1 answer

Search in xlsx and xls file using java

I have a large xlsx file which as huge amount of data on which I have to implement search option I have used Apache POI jar as well as jxl jar so that the search between rows and column have been made. But it took huge time to traverse between big…
ashokramcse
  • 2,841
  • 2
  • 19
  • 41
10
votes
8 answers

Get String value, when I read from excel with Date type (apache poi)

I have an xlsx file that I am reading with - Apache POI Library. For example, In some row, I have such cells values: 01-Sep-13 | 15136.00| Matt|...... My goal is: Read all cells in the rows as String values. But as I see, I can't read…
Sergii Lisnychyi
  • 477
  • 4
  • 10
  • 16
10
votes
6 answers

How to get cell's background color using apache poi?

How do we get background color of a XSSFCell. I tried using XSSFCellStyle but no luck. FileInputStream fis = new FileInputStream(fileName); XSSFWorkbook book = new XSSFWorkbook(fis); XSSFSheet sheet = book.getSheetAt(0); XSSFRow row =…
AAA
  • 348
  • 1
  • 4
  • 19
10
votes
2 answers

org.apache.xmlbeans.impl.values.XmlValueDisconnectedException when write workbook twice

i'm create a method to write and read work book from file but when i call this method second time. error occure : org.apache.xmlbeans.impl.values.XmlValueDisconnectedException public XSSFWorkbook GetUpdatedResult(XSSFWorkbook…
Nikesh Pathak
  • 450
  • 2
  • 7
  • 18
10
votes
2 answers

Insert picture in word document

This is the first time I am working on Apache POI and the question which I am going to ask has been asked already on this site but no clear answer were given for them so I have no choice but to take all your help. I am trying to write a java program…
Amitabh Ranjan
  • 1,500
  • 3
  • 23
  • 39
10
votes
3 answers

setting cell style not working

i'm working with apache poi and XLSX file. i use xssf classes to dynamically create a spreadsheet. i'd like to set cell's style in a for loop, but it doesn't seem to work...here's my code : for(int…
Medioman92
  • 581
  • 4
  • 10
  • 21
10
votes
1 answer

Merging cells in an excel output in POI

I am able to create the following excel using POI: As clear from the image, each table is having two values viz. Val One and Val Two. However, I want the Table Name two cells to be merged into one cell in the first column as below: How to achieve…
Vicky
  • 16,679
  • 54
  • 139
  • 232
10
votes
2 answers

Apache POI autoSizeColumn() not working right

I am creating a program that writes information to an excel file using the apache poi. After I enter all of my data into the file I call the autoSizeColumn method on every column of the file. But it resizes the columns to the width of the last cell…
Billy Stalnaker
  • 146
  • 1
  • 1
  • 10
10
votes
2 answers

Reading time values from spreadsheet using poi api

I am trying to read a date column and a time column from a spreadsheet. I am able to retireve the date column from the sheet, but not the time column. For example, my sheet will have rows of the form: date time 11/2/2012 …
CuriousCoder
  • 1,582
  • 5
  • 28
  • 55
10
votes
3 answers

Iteration through multiple sheet of excel in java

I am very new to java. I am creating pList from excel. My excel file contains multiple sheets. I want to iterate through all the sheets of the excel file. How to to this? please help.
hgpl
  • 869
  • 4
  • 11
  • 20