Java jExcel正在获取缺少的单元格内容

Java jExcel正在获取缺少的单元格内容,java,excel,jexcelapi,Java,Excel,Jexcelapi,我正确地读取了excel文件。例如,我的单元格内容是excel文件中的0987654321。当我使用jExcel api读取它时,我只读取了单元格的几个字符。例如0987 以下是我的read excel代码部分: Cell A = sheet.getCell(1, 1); String stringA = A.getContents().toString(); 如何解决该问题。我需要单元格的所有内容。getContents()是将单元格内容作为字符串获取的基本例程。通过将单元格强制转换为适

我正确地读取了excel文件。例如,我的单元格内容是excel文件中的0987654321。当我使用jExcel api读取它时,我只读取了单元格的几个字符。例如0987

以下是我的read excel代码部分:

 Cell A = sheet.getCell(1, 1);
 String stringA = A.getContents().toString();
如何解决该问题。我需要单元格的所有内容。

getContents()
是将单元格内容作为字符串获取的基本例程。通过将单元格强制转换为适当的类型(在测试它是否为预期类型之后),您可以访问包含的原始数值,如下所示

if (A.getType() == CellType.NUMBER) {
    NumberCell nc = (NumberCell) A;
    double doubleA = nc.getValue();
    // this is a double containing the exact numeric value that was stored 
    // in the spreadsheet
}
这里的关键信息是:您可以通过强制转换到适当的单元格子类型来访问任何类型的单元格。
所有这些以及更多内容将在

中解释,简而言之:

if (A.getType() == CellType.NUMBER) {
    double doubleA = ((NumberCell) sheet.getCell(1, 1)).getValue();
}