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
11
votes
2 answers

How to detect a zip-bomb with Java 10

Apache POI is opening zip-files on a regular basis because Microsoft Excel/Word/... files are zip-files in their newer format. In order to prevent some types of denial-of-service-attacks, it has functionality when opening Zip-files to not read files…
centic
  • 15,565
  • 9
  • 68
  • 125
11
votes
1 answer

Android POI : crash when using autoSizeColumn()

autoSizeColumn method of POI throws an exception that I didn't manage to resolve : "java.lang.ClassNotFoundException: Didn't find class "java.awt.font.FontRenderContext" on path:..." with this error "java.lang.NoClassDefFoundError: Failed…
Paul Lemesnager
  • 119
  • 1
  • 10
11
votes
4 answers

GC overhead limit exceeded with Apache POI

I have 13 .xlsx files with about 1000 rows in each of them. Now I want to merge it to one .xlsx file with one sheet. I'm using code from here https://blog.sodhanalibrary.com/2014/11/merge-excel-files-using-java.html#.Vi9ns36rSUk. Here's my code (few…
Marquess
  • 141
  • 1
  • 1
  • 4
11
votes
2 answers

Multiple Styles to Excel Cell POI

I want to apply colour to cell as well as Format Cell value(e.g. Date,Amount).But when I am applying two Cell Style only the last style is gets applied on cell. //before this colourCellStyle and dateCellStyle are the formatting style cell9 =…
rupesh_padhye
  • 1,355
  • 2
  • 13
  • 25
11
votes
1 answer

Infinite bogus pages in outpout docx using Apache Poi

So... basically I have a docx file. And I have to do some formatting changes in few paragraphs and then save in a new file. What I am doing is essentially following. import scala.collection.JavaConversions._ import…
sarveshseri
  • 13,738
  • 28
  • 47
11
votes
2 answers

Creating a CellStyle library in Apache POI

My system produces lots of different Excel reports using Apache POI from Java. A lot of these reports share the same styles. I have created a CellStyle library for use by all of the reports. I wondered if there was a neater way. import…
gordon613
  • 2,770
  • 12
  • 52
  • 81
11
votes
5 answers

Merging Two excel files as two sheets in one workbook in java

I have two xlsx files at folder C:\DemoFilesExcel\demo1.xlsx and C:\DemoFilesExcel\demo2.xlsx. I want to create a new xlsx C:\DemoFilesExcel\merged.xlsx that will have these two files as two sheets in merged.xlsx workbook. This is to be done using…
user3274923
  • 121
  • 1
  • 2
  • 5
11
votes
4 answers

xssf How to get anything as String

I try to parse an excel file into XML using apache poi xssf. Now having a cell and not knowing what is in it I just want to get a String out of it. But when I use cell.getStringCellValue() it throws an exception, what is not very suprising since it…
mxcd
  • 1,954
  • 2
  • 25
  • 38
11
votes
1 answer

Does POI XSSF still have crazy bad memory issues?

A couple years ago, I ran into issues where I was creating large excel files using jXLS and POI XSSF. If my memory is correct, I think XSSF would create something like 1GB+ temp files on the disk to create 10mb excel files. So I stopped using jXLS…
Bob Thule
  • 691
  • 9
  • 15
11
votes
2 answers

null pointer exception apache poi

hi we've been reading xls and xlsx file using apache poi ing our java program, the problem is we are getting null pointer exception with two reasons.. the first 1 is the blank cell which we already solved and the other one is when we are choosing a…
y.reyes
  • 117
  • 1
  • 2
  • 8
11
votes
2 answers

Reading and writing from xls and xlsx excel file in java using Apache POI

I am writing a program which needs to read and write from excel files, irrespective of the format(xls or xlsx). I am aware of the Apache POI, but it seems it has different classes to handle xls file(HSSF) and xlsx(XSSF) files. Anyone aware of how I…
willowherb
  • 837
  • 1
  • 13
  • 21
11
votes
2 answers

How to Determine Merged Cells in a Certain Row

Here's what I know so far: You use the method sheet.getNumMergedRegions() to get the number of merged regions in a particular sheet You loop through each count and use the method sheet.getMergedRegion(i) and assign to a CellRangeAddress…
Israel Sato
  • 199
  • 1
  • 2
  • 12
11
votes
2 answers

How to change the specific text color in a same cell of excel sheet using apache poi?

Does anyone know how to change the color of the particular text of a cell in excel. I am using apache poi and I could find out to change the text color of entire cell. But I want only a particular text. Eg: Cell A1 has Hello World I want "Hello" to…
user001
  • 991
  • 6
  • 16
  • 34
11
votes
8 answers

How do I get the (Java Apache POI HSSF) Background Color for a given cell?

I have an existing excel spreadsheet, which I am accesssing and reading values from, I am using Apache POI HSSF. It is initialised like this: HSSFSheet sheet; FileInputStream fis = new FileInputStream(this.file); POIFSFileSystem fs = new…
java
  • 151
  • 1
  • 2
  • 6
11
votes
4 answers

Adding border to a merged region in POI XSSF workbook

I'm using apache poi 3.7 and I need to put border to a range of cells or merged region. how can I to apply border to a merged region when the sheet and workbook type is XSSF. In HSSF type I use RegionUtil-/HSSFRegionutil, but if use the first…
Charlessmori
  • 217
  • 2
  • 3
  • 10