Bug 55505

Summary: CountryRecord not found
Product: POI Reporter: Martin Studer <martin.studer>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
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