Die*_*ego 3 java nullpointerexception jopendocument
在 Libreoffice 电子表格的工作表中,我可以访问单元格,但不能访问其值。我没有发现我的错误,欢迎任何反馈。这是代码:
import java.io.File;
import java.io.IOException;
import org.jopendocument.dom.spreadsheet.MutableCell;
import org.jopendocument.dom.spreadsheet.Sheet;
import org.jopendocument.dom.spreadsheet.SpreadSheet;
public class MyClass {
protected Sheet dataSheet;
protected File dataCalcFile;
public static void main(String[] args) {
MyClass myClassInstance = new MyClass();
myClassInstance.loadData();
}
public void loadData() {
int numRows=0, numColumnas=0;
MutableCell cell=null;
try {
dataCalcFile = new File(""C:\\temp\\Data.ods"");
dataSheet = SpreadSheet.createFromFile(dataCalcFile).getSheet(0);
numRows = dataSheet.getRowCount();
System.out.println("Number of rows: " + numRows);
System.out.println("Cell at 0,0: " + dataSheet.getCellAt(0, 0));
System.out.println("Nullpointer Exception when getting cell value at 0,0: " + dataSheet.getValueAt(0, 0)); // *** THE INFAMOUS ONE ***
} catch (Exception e) {
System.out.println(e);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是控制台的输出:
Number of rows: 107
Cell at 0,0: <table:table-cell xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" table:style-name="ce1" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:value-type="string" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" calcext:value-type="string"><text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0">Carpeta</text:p></table:table-cell>
java.lang.NullPointerException
Run Code Online (Sandbox Code Playgroud)
小智 5
刚刚发现:“是的,LO 7 切换到 OpenDocument 1.3。我们正在努力支持它。同时,您可以将格式更改为“1.2 扩展”。转到“选项”,然后“加载/保存”,然后“常规”,然后是 ODF 格式版本。”
它对我有用,但很高兴听到我的客户的意见......
| 归档时间: |
|
| 查看次数: |
671 次 |
| 最近记录: |