在Excel文件中获取单元格的超链接
我正试图使用这个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 at com.monitorjbl.xlsx.impl.StreamingCell.getHyperlink(StreamingCell.java:353)at com.z2data.mapping.ExeclHorizental.getCurrentRow(ExeclHorizental.java:88)
超链接不是一个string。 实例化一个超链接。 尝试这个:
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()); }
- Apache POI&SXSSF:行数始终为0
- 在尝试从Java(POI API)设置excel中的cellvalue时,单元格值不会复制到正确的行中
- org.apache.poi.POIXMLException目前不支持严格的OOXML,请参阅bug#57699
- 将SXSSF保存为.xls文件
- 有没有办法在Apache POI中引用XLA文件?
- 在使用autosizeColumn的Apache POI 3.9中,呈现在同一列上的图像越来越窄
- 使用spring批处理和apache poi写入来自多个源的数据
- 在Servlet端生成带有Excel表格的内存zip文件
- 如何使用Apache POI在1或2张excel文件中查找特定的string?