Bug 61605 - An error occurred when cloning a sheet containing a hyperlink
Summary: An error occurred when cloning a sheet containing a hyperlink
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.16-FINAL
Hardware: PC All
: P2 critical with 4 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-11 13:29 UTC by Mike
Modified: 2018-12-28 11:24 UTC (History)
0 users



Attachments
Example Excel file (10.77 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2017-10-11 13:29 UTC, Mike
Details

Note You need to log in before you can comment on or make changes to this bug.
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.