开发者

Why is a cell value returned as an empty string even though it has content?

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 ran into is: Inside the XLS file I have a column of cells that is filled with serial-numbers by the user. When the Java application gets the cell, it has a cell type STRING. And when I ask for the string value of the cell I get an empty string.

The file is originally created by the application, then the users fill it with data and load it back into the a开发者_StackOverflow中文版plication. So I don't think the file format is wrong, since it's created by the same version of the API.

What could be the problem?

EDIT:

Clarification: We upgraded Office installation to 2007, but the application still uses HSSF and XLS format. Only the users open and edit the files with Office 2007. Is that a problem?


Have you checked if Excel automatically switched the cell type to NUMERIC when the user entered the value?
Excel has this annoying feature to "intelligently guess" what kind of value the user enters which then often causes a problem in POI.


HSSF is the POI Project's pure Java implementation of the Excel '97(-2007) file format. XSSF is the POI Project's pure Java implementation of the Excel 2007 OOXML (.xlsx) file format.

read furthur http://poi.apache.org/spreadsheet/index.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜