2
我試圖用POI SS到Excel電子表格轉換爲CSV。不幸的是,我似乎無法正確處理HYPERLINK功能:如何使用POI SS處理HYPERLINK功能?
if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
System.out.println("formula cell: " + cell.toString());
switch (cell.getCachedFormulaResultType()) {
case Cell.CELL_TYPE_BOOLEAN:
return Boolean.toString(cell.getBooleanCellValue());
case Cell.CELL_TYPE_NUMERIC:
return NUMERIC_FORMAT.format(cell.getNumericCellValue());
case Cell.CELL_TYPE_BLANK:
return "";
default:
// Special case handling for HYPERLINK cells
if (cell.getHyperlink() != null) {
System.out.println("found hyperlink: " + cell.getHyperlink().getAddress());
return cell.getHyperlink().getAddress();
}
System.out.println("something else: " + cell.toString());
return cell.toString();
}
}
不幸的是,儘管它解釋這種細胞作爲公式的單元格,cell.getHyperlink()返回null所以cell.toString()僅返回全公式,如:
= HYPERLINK( 「HTTP:...」, 「...」)
我如何使其正常工作?
實際評估超鏈接的值()方法見http://stackoverflow.com/questions/15757243/how-to-read-result-of-hyperlink-function-in-poi/ – centic 2013-04-02 07:00:57