Reputation: 3012
I 'am trying to get hyperlink and label of a cell in Excel file using this
library (this library is based on apache POI)
https://github.com/monitorjbl/excel-streaming-reader#supported-methods
I tried this
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();
but I get this Exception
com.monitorjbl.xlsx.exceptions.NotSupportedException at com.monitorjbl.xlsx.impl.StreamingCell.getHyperlink(StreamingCell.java:353) at com.z2data.mapping.ExeclHorizental.getCurrentRow(ExeclHorizental.java:88)
Upvotes: 1
Views: 657
Reputation: 1295
Hyperlink is not a a string. Instantiate a Hyperlink instead. Try this:
Hyperlink h = currentCell.getHyperlink();
You can then fetch the address of the particular cell
if (h == null) {
System.err.println("Cell didn't have a hyperlink!");
} else {
System.out.println("Cell : " + h.getLabel() + " -> " + h.getAddress());
}
Upvotes: 1