Bug 61605

Summary: An error occurred when cloning a sheet containing a hyperlink
Product: POI Reporter: Mike <goodby>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED WORKSFORME    
Severity: critical    
Priority: P2    
Version: 3.16-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Example Excel file

Description Mike 2017-10-11 13:29:26 UTC
Created attachment 35410 [details]
Example Excel file

Hi, guys.
I use POI 3.16

When I clone a sheet that contains hyperlinks, I get an error message:
  java.lang.IllegalStateException: The hyperlink for cell B5 references relation rId1, but that didn't exist!
	at org.apache.poi.xssf.usermodel.XSSFHyperlink.<init>(XSSFHyperlink.java:71)
	at org.apache.poi.xssf.usermodel.XSSFSheet.initHyperlinks(XSSFSheet.java:254)
	at org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:207)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.cloneSheet(XSSFWorkbook.java)

My code:
XSSFWorkbook template_wb;
XSSFSheet template_sh = null, source_sh = null;

//get Excel file as Blob from Oracle database
Blob lBlob = GetExcelTemplateAsBlob( PNHTemplateId, ExcelTemplateName );
lBlobStream = lBlob.getBinaryStream();
        
template_wb = new XSSFWorkbook( lBlobStream );
template_sh = template_wb.getSheetAt( 0 );      
source_sh = template_wb.cloneSheet( 0 ); <- here I get an error

If the sheet does not contain hyperlinks, then all is successful.
Example of a file in an attachment.
Best regards.
Mike
Comment 1 Dominik Stadler 2018-12-28 11:24:58 UTC
I tried to reproduce this with latest POI (4.0.1) but could not, so this is likely fixed in the meantime.