apache-poi

How to differentiate between excel 2007 and older excel files in java using apache poi ?

I have an app that takes excel files as input. Currently, it supports older excel files through the package hssf of the apache poi library. This library can handle excel 2007 files too, through the use of the xssf package. My question is : if you receive a file, knowing that you cannot be sure if the file extension (xls or xlsx) is ...

Updating values of custom properties in word doc using java

I am not able to update value of a custom property in a word document using java. I have a word document which contains a custom property with value 'stack'. Using java I want to change that value to 'overflow'. I used two approaches. 1) Using Apache POI I set the org.apache.poi.hpsf.CustomProperties in org.apache.poi.hpsf.DocumentSu...

How do I find out Apache Buildr/Maven 2 repo names

I'm just starting to use Apache Buildr and I'm constantly running into the problem of not knowing what repo urls and versions are available for me to use. For example I want to use Scala 2.8 in a build file, the id i previously used was: 2.8.0-SNAPSHOT But now this is not found. I also want to use the latest version of Apache POI. If...

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... thanks in advance EDIT: i'm dealing with XLSX files ...

Learning Apache POI for Java

I'm trying to learn Apache POI for Java quickly (for manipulating Excel). I've been googling for tutorials, but so far all I've found is short, 2-paragraph explanations followed by a code sample. I wanted to find something a bit more comprehensive, that is concise but walks through it in a structured, complete, and understandable way. An...

Apache POI Excel Row & Column Indexing

I'm using Apache POI to create a large Excel spreadsheet that is extremely formula heavy for a client that may later modify the code of my program with new formulas. The big issue that I'm running in to is dealing with the fact that the POI workbooks are 0-indexed for their rows and columns, while the Excel formulas deal with the documen...

creating cell comments using HSSFClientAnchor in apache poi

Could someone please explain to me how to properly use the Anchors when creating cell comments? Mine were working, but the spread sheet changed and I am having issues getting my cell comments to appear. This is the code I was using that worked: Comment c = drawing.createCellComment (new HSSFClientAnchor(0, 0, 0, 0, (short)4, 2, (short)...

Are POI colors limited to IndexedColors?

I'm trying to set Excel cell colors using Apache POI in Java. I played around in Excel itself and chose the colors I wanted - but I can't figure out how to use those colors with POI. I'm using the font.setColor method, which takes a short that's the index of a color... Which seems to indicate that I'm limited to the constants in IndexedC...

How to set formulas in cells using Apache POI?

Currently I am using Apache POI for java to set formulas for cells, but the problem is after I run the program, and open the excel file that i created and processed with my java program, the cells with the formula included the formula as a string, rather than the value the formula should have returned. ...

decrypt excel files

Hi I have 1000 encrypted workbooks which I would like to decrypt by providing a pwd. I could not find a decrypt method under apache poi or python's xlrd module. Does anyone know a library which could handle this (wbc.decrypt(pwd)). I would prefer a lib i could you use from a unix box. Thanks ...

Problem when extracting excel data using POI in JAVA?

I have just Extracted the cells from the excel sheet using POI, everything is working fine. But whenever there is an empty cell, the very next right cell data is what I get as a output. But, if exists a value in the latter, the desired output is coming. This is the logic i've written. Iterator<Row> rowIterator=sheet.rowIterator(); ...

How can i apply a dateformat style to one column in Excel with POI-3.2-FINAL ?

Hello everyone, I have to create an excel file with POI-3.2-Final (can't upgrade to 3.5+, for retro compatibility issues) and for each row, i have to format a date in col A. Based on the method names, i thought the way to do it was : short dateFormat = workbook.createDataFormat().getFormat("dd/MM/yyyy HH:mm"); ... cell = row.createCel...

Errors in Excel extraction from Java using Apache POI cause need to restart service

I'm using Apache POI for extracting data from Excel into java. If there any error happens while the page is loading, then we have to restart the tomcat service. For example, I am extracting the data from Excel, if excel has no issues, then the incoming data is correct. If there is any error I get a null pointer exception, and after that...

How can I create a simple docx file with Apache POI?

I'm searching for a simple example code or a complete tutorial how to create a docx file with Apache POI and its underlying openxml4j. I tried the following code (with a lot of help from the Content Assist, thanks Eclipse!) but the code does not work correctly. String tmpPathname = aFilename + ".docx"; File tmpFile = new File(tmpPathna...

Streaming a POI workbook to the servlet output stream.

I build a very large POI workbook, on my web server. Holding the entire workbook in memory , will not scale for multiple concurrent requests. Is there a way i can progressively write the workbook to the servlet output stream. That should reduce the response time , as well as make the process memory efficient. ...

Problem with using APACHE-POI to convert PPT to Image

Hi all, I got a problem when I try to use Apache POI project to convert my PPT to Images.My code as follows: FileInputStream is = new FileInputStream("test.ppt"); SlideShow ppt = new SlideShow(is); is.close(); Dimension pgsize = ppt.getPageSize(); Slide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { Buffered...

How to group a database write and spreadsheet write in single "transaction"

I have a Java program that writes results to both a DB (SQL Server) and a spreadsheet (POI), and it would be best if neither is written to if there's an error with either. It would be a lot worse if the spreadsheet was produced and then an error happened while saving to the DB, so I'm doing the DB-write first. Even so, I'm wondering ...

Store number in Excel using Apache POI.

Hi All, I am using Apache POI to store data in excel sheet. I can store data like "50%" in the cell. Excel also shows up, but it show error like "Number stored as String". If i click that message and click "convert number to String". It shows perfectly. How to store it without errror using POI ...

Setting foreground color for HSSFCellStyle is always coming out black

I am using POI to create an Excel spreadsheet in Java. I have the following code used for creating a header row: HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("Report"); // some more code HSSFRow row = sheet.createRow(0); HSSFCell cell = row.createCell(cellNumber); HSSFCellStyle cellStyle = wb.createCellStyle...

Embedding HSSF(excel) into HSLF(ppt) using apache poi

I want to embed the excel sheet into presentation(PPT) using apache poi. how can we do this? If anyones knows, please help me. ...