我正在尝试使用此文件在Excel文件中获取超链接和单元格的标签
库(此库基于apache POI)
https://github.com/monitorjbl/excel-streaming-reader#supported-methods
我试过了
InputStream is = new FileInputStream("file");
Workbook workbook = StreamingReader.builder().rowCacheSize(100)
.bufferSize(4096)
.open(is);
Iterator<Row> rowIterator=workbook.getSheetAt(0).iterator();
Row row=rowIterator.next();
Iterator<Cell> cellIterator = row.cellIterator();
Cell currentCell = cellIterator.next();
String parthyperlink=currentCell.getHyperlink().getAddress();
String label=currentCell.getHyperlink().getLabel();
但是我得到这个异常
com.monitorjbl.xlsx.exceptions.NotSupportedException位于
com.monitorjbl.xlsx.impl.StreamingCell.getHyperlink(StreamingCell.java:353)
在
com.z2data.mapping.ExeclHorizental.getCurrentRow(ExeclHorizental.java:88)
最佳答案
超链接不是字符串。而是实例化一个超链接。尝试这个:
Hyperlink h = currentCell.getHyperlink();
然后,您可以获取特定单元格的地址
if (h == null) {
System.err.println("Cell didn't have a hyperlink!");
} else {
System.out.println("Cell : " + h.getLabel() + " -> " + h.getAddress());
}