Bug 55505

Summary: CountryRecord not found
Product: POI Reporter: Martin Studer <martin.studer>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal Keywords: APIBug
Priority: P2    
Version: 3.10-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Excel file to reproduce issue

Description Martin Studer 2013-08-29 19:30:40 UTC
Created attachment 30785 [details]
Excel file to reproduce issue

Attached is an xls file that was produced via Crystal Reports. Opening the file and trying to add a sheet leads to the following exception:

Exception in thread "main" java.lang.RuntimeException: CountryRecord not found
	at org.apache.poi.hssf.model.LinkTable.<init>(LinkTable.java:265)
	at org.apache.poi.hssf.model.InternalWorkbook.getOrCreateLinkTable(InternalWorkbook.java:1794)
	at org.apache.poi.hssf.model.InternalWorkbook.checkSheets(InternalWorkbook.java:741)
	at org.apache.poi.hssf.model.InternalWorkbook.setSheetName(InternalWorkbook.java:585)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.createSheet(HSSFWorkbook.java:789)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.createSheet(HSSFWorkbook.java:73)


The code to reproduce this is:

Workbook wb = WorkbookFactory.create(new File("ReportB.xls"));
wb.createSheet("test");

Opening the file in Excel and saving it again produces a file that can be read and modified without any problems. I guess Excel simply assumes a default CountryRecord in this case. If this is the case, it would probably make sense to assume a default CountryRecord as well rather than throwing an exception.
Comment 1 Andreas Beeker 2020-04-21 22:15:10 UTC
fixed via r1876805
Comment 2 cpanon 2020-06-04 14:32:15 UTC
as of poi 4.1.2 with HSSF still a problem with Crystal Reports(CR) generated files, but not all xls generated CR reports.  Happens with "sheet.shift(x,y,z)
It is fixed opening in Excel and saving, not possible in production or processing an InputStream.  Is there a default CountryRecord that can be created and assigned to prevent this through the API?  tia.

java.lang.RuntimeException: CountryRecord not found
Comment 3 PJ Fanning 2020-06-04 14:35:07 UTC
please do not reopen issues - the recent changes are not yet released - will be in 5.0.0 release when that is ready for release