【发布时间】:2014-12-11 09:45:46
【问题描述】:
我正在编写一个使用 apache POI 读取 excel 文件的程序。我得到了所有的值,但我想知道哪些单元格依赖于其他单元格(使用单元格的公式)。
我试过使用String formula = cell.getCellFormula(),但这只是返回单元格索引(例如H5)。我还有其他方法可以做到这一点吗?
这是我读取单元格的代码:
private void handleCell(int type,Cell cell)
{
switch (type)
{
case Cell.CELL_TYPE_STRING:
System.out.print(cell.getStringCellValue() + "\t\t");
break;
case Cell.CELL_TYPE_NUMERIC:
System.out.print(cell.getNumericCellValue() + "\t\t");
break;
case Cell.CELL_TYPE_BOOLEAN:
System.out.print(cell.getBooleanCellValue() + "\t\t");
break;
case Cell.CELL_TYPE_FORMULA:
String form = cell.getCellFormula();
handleCell(cell.getCachedFormulaResultType(),cell);
break;
default :
}
}
【问题讨论】:
标签: java excel apache apache-poi