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
12
votes
4 answers

Convert Excel Spreadsheets to HTML using the Apache POI library

I am trying to use ExcelToHtmlConverter class to convert a word document in HTML, but the documentation is not clear. Does anyone have a sample program on how to load a excel document and convert it into html.
user1162040
  • 169
  • 2
  • 3
  • 5
12
votes
3 answers

Setting a part of the cell contents to bold using apache poi?

How can i put this string in to a cell using java apache poi? The string is "Hello world Hello" As u can see i need to make a part of the text bold? I'm able to set the entire contents of the cell to bold but not specific parts. Please help me.
Saicharan S M
  • 828
  • 3
  • 11
  • 25
12
votes
2 answers

Java POI: How to find an Excel cell with a string value and get its position (row) to use that position to find another cell

I'm looking for a cell in a spreadsheet that has the string 'Total' and then use the row in which that cell is to find the total value in another cell which is always the same cell/column (the 10th cell in a 0 based index). I have the following…
lv10
  • 1,469
  • 7
  • 25
  • 46
12
votes
5 answers

Java Excel/POJO Mapping in POI

Java 8 here using Apache POI 4.1 to load Excel (XLSX) files into memory, and write lists of Java beans/POJOs back to new Excel files. To me, an Excel file (at least the ones I'm working with) is really a list of POJOs, with each row being a…
hotmeatballsoup
  • 385
  • 6
  • 58
  • 136
12
votes
4 answers

Apache POI evaluate formula

I have some formulas in cells of my sheet, and I want to evaluate them after I insert some values. Ex : My formula is =SUM(B1,B2) Before values insertion B1 value was 1, and B2 value was 3, and the formula result is 4 After insertion of values now…
ant
  • 22,634
  • 36
  • 132
  • 182
12
votes
5 answers

CELL_TYPE_STRING cannot be resolved or is not a field

Stack trace Exception in thread "main" java.lang.Error: Unresolved compilation problems: CELL_TYPE_STRING cannot be resolved or is not a field CELL_TYPE_NUMERIC cannot be resolved or is not a field CELL_TYPE_BOOLEAN cannot be resolved or is not…
lenin kumam
  • 121
  • 1
  • 1
  • 5
12
votes
3 answers

Create Bar Chart in Excel with Apache POI

I'm trying to create a Bar Chart in an XLSX Spreadsheet using Apache POI, but Excel keeps saying that there's a problem with the content and deleting the chart when I try to open the file. Here's the full code of what I'm trying to do: public static…
luthier
  • 2,674
  • 4
  • 32
  • 35
12
votes
4 answers

How can I get an Input Stream from HSSFWorkbook Object

I want my web application users to download some data as an Excel file. I have the next function to send an Input Stream in the response object. public static void sendFile(InputStream is, HttpServletResponse response) throws IOException { …
Sergio del Amo
  • 76,835
  • 68
  • 152
  • 179
12
votes
2 answers

Apache POI much quicker using HSSF than XSSF - what next?

I've been having some issues with parsing .xlsx files with Apache POI - I am getting java.lang.OutOfMemoryError: Java heap space in my deployed app. I'm only processing files under 5MB and around 70,000 rows so my suspicion from reading number other…
slugmandrew
  • 1,776
  • 2
  • 25
  • 45
12
votes
2 answers

How put a image in a cell of excel java?

I have tried to put an image into an Excel cell with java but without much success this is the code I was working but the only thing I've done is put the image on excel sheet but not in a cell specified XSSFWorkbook wb = new XSSFWorkbook(); Sheet…
Bakke Medina
  • 307
  • 2
  • 3
  • 10
12
votes
12 answers

"Package should contain a content type part [M1.13]"

I am attempting to write to an Excel file however I keep getting the error: Exception in thread "main" org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part…
Tephrite
  • 135
  • 1
  • 1
  • 5
12
votes
2 answers

Setting custom font color for XSSFWorkbook in Apache POI

I'm having a little trouble with setting a custom font color for an XSSFWorkbook from Apache POI. When I do: yellow = workbook.createCellStyle(); Font whiteFont = workbook.createFont(); whiteFont.setColor(new XSSFColor(new Color(255,…
silverAndroid
  • 960
  • 3
  • 11
  • 29
12
votes
1 answer

What is CTP, CTTbl classes (objects) in Apache POI?

I'm trying to understand some parts of Apache POI. For instance, i;m trying to get text (or table, etc.) from an existing docx file. For example there is a method getParagraph(..CTP p) in XWPFDocument: It returns "a paragraph with a CTP class p".…
Emptyfruit
  • 303
  • 2
  • 11
12
votes
2 answers

Apache POI difference between cloning style and getting style

Are there any significant differences between doing: CellStyle newCellStyle = workbook.createCellStyle(); neweCellStyle.cloneStyleFrom(oldCell.getCellStyle()); newCell.setCellStyle(newCellStyle); versus CellStyle newCellStyle =…
Stupid.Fat.Cat
  • 10,755
  • 23
  • 83
  • 144
12
votes
9 answers

How to remove warning in Excel using apache poi in JAVA?

I am using apache poi api to generate Excel sheet in my application in java. Data that are set in excel are coming dynamically with type string. For column1, values are alphanumeric. When I generate Excel, it will give me green indication with…
Charvee Shah
  • 730
  • 1
  • 6
  • 21