poi-hssf

IndexOutOfBoundsException when trying to read MS Excel file using Apache POI-HSSF

Whilst trying to parse MS Excel file using POI-HSSF v3.2 I am getting IndexOutOfBoundsException. The spreadsheet I am trying to read isn't empty it has been created using MS Excel 2003 and BiffViewer included with the POI package has no problem parsing it. My code is as follows: package src; import java.io.*; import org.apache.poi.hss...

Reading date values from excel cell using POI HSSF API

I'm using POI HSSF API for my excel manipulations in Java. I've a date value "8/1/2009" in one of my excel cell and while I try to read this value using HSSF API, it detects the cell type as Numeric and returns the 'Double' value of my date. See the sample code below: cell = row.getCell(); // date in the cell '8/1/2009' switch (cell.get...

Is there a way to display a HSSFWorkbook Object in a JSP page?

Is there a way to Display a HSSFWorkbook Object in a JSP page without having an output file in the server side. In the code below I am providing the template file and the beans required for net.sf.jxls.transformer.XLSTransformer.transformXLS(InputStream is, Map beanParams) to return me a HSSFWorkbook object. I now need a way to use this ...

How can we read protected password excel file (.xls) with POI API

Hello everyone. I've just learned POI and find the HSSF is very simple to read and create excel file (.xls). However, I found some problem when want to read excel protected with password. It took me an hour to find this solution on internet. Please could you help me to solve this problem. I'm very glad if you could give me a code sni...

Reading string value from Excel with HSSF but it's double

Hi, I'm using HSSF-POI for reading excel data. The problem is I have values in a cell that look like a number but really are strings. If I look at the format cell in Excel, it says the type is "text". Still the HSSF Cell thinks it's numeric. How can I get the value as a string? If I try to use cell.getRichStringValue, I get exception; i...

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

Hello, 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 POIFSFileSystem(fis); HSSFWorkbook wb = new HSSFWorkbook(fs); this.sheet = wb.getSheet(exsh...

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

Hi, 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 make myself clearer, here is a simple example : Cell A1 contains "1",B1 contains ...

Extracting charts from Excel documents using POI or HSSF?

I've got a bunch of Excel documents that have data on one sheet and a chart produced from the data on another sheet. I'd like to take those documents and produce a series of HTML pages from them. Using POI (or HSSF) know I can read the data from the documents and produce a chart using some charting engine. But the customer's not happy wi...

All images on sheet disappear when I call getDrawingPatriarch...

Hi, everybody! I have an excel template with images... When I simply populate it with data everything works fine. But I need programmaticly to add comments to cells sometimes, and the only way I found is to use HSSFPatriarch. But when I call HSSFSheet.getDrawingPatriarch() all images on sheet disappear... So the question is: 1. Is there...

Writing HTML to EXCEL file using POI API

Hi, I am trying to write a HTML String directly onto an EXCEL sheet using POI API. The HTML tags are retained on the EXCEL sheet. How do I get EXCEL to render it correctly without the HTML tags? ...

How to know number of sheets in a workbook?

I'm using hssf api for reading data from xls files. But is there any way to get the exact no. of sheets in a workbook containing stored data? ...

copy or clone a HSSFWorkbook

Hi, Currently I am doing the following in a loop (at least 300 times): - create a HSSFWorkbook from a template file - add some values to specific cells in the workbook - save the workbook as a new excel file The first line takes about 70% of the time (reading excel file). What I would like to do is to take this out of the loop, and rea...

How to determine whether a spread-sheet cell contains a date, or a real number?

When a cell in a spreadsheet contains a simple date (mm/dd/yyyy) the poi API flags the cell-type as 'numeric'. This is probably because spreadsheets ( IMO ) historically recognize only strings and real numbers. It is possible to hard-code the cell-index, and use it conditionally to call 'getDateCellValue'. But this feels like a hack. ...

Apache POI HSSF does not write data correctly

Hi, I am working on a project using Apache POI HSSF. In this project I import data from some spreadsheets and export the imported data to another spreadhseet. This all works fine but there is one little flaw: When I export the data to a spreadsheet it seems like it isn't written finally. When I open the document in Excel all values are...

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...

HSSFCell created with Numeric format changes to Date format on editing in Excel

Hi, I am using HSSF-POI(3.2) for writing an Excel file(2003). The structure of a row is: DATE_COL1, NUM_COL1, DATE_COL2, DATE_COL3, DATE_COL4, NUM_COL2; DATE_COLs and NUM_COLs are formatted as dates and numerics respectively. While creating the sheet I dynamically set the formats and the data too, which gets set correctly. On editing th...

POI HSSF Java Excel: Cell value returns as empty string even though it has content

Hi, I wrote a Java method that uses POI HSSF API to convert an Excel file to my data structure. The code worked just fine for a while. But now there are suddenly problems. I suspect it might be because recently we installed Office 2007 on all the client computers (previously we had Office 2003). The problem I run into is this: inside t...