#55505 - CountryRecord not found

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1876805 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2020-04-21 22:13:59 +00:00
parent c8a5bdf22a
commit 778f4f5d7d
3 changed files with 15 additions and 2 deletions

View File

@ -30,6 +30,7 @@ import org.apache.poi.hssf.record.ExternalNameRecord;
import org.apache.poi.hssf.record.NameCommentRecord; import org.apache.poi.hssf.record.NameCommentRecord;
import org.apache.poi.hssf.record.NameRecord; import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.SSTRecord;
import org.apache.poi.hssf.record.SupBookRecord; import org.apache.poi.hssf.record.SupBookRecord;
import org.apache.poi.ss.formula.SheetNameFormatter; import org.apache.poi.ss.formula.SheetNameFormatter;
import org.apache.poi.ss.formula.ptg.Area3DPtg; import org.apache.poi.ss.formula.ptg.Area3DPtg;
@ -271,7 +272,10 @@ final class LinkTable {
int idx = findFirstRecordLocBySid(CountryRecord.sid); int idx = findFirstRecordLocBySid(CountryRecord.sid);
if (idx < 0) { if (idx < 0) {
throw new RuntimeException("CountryRecord not found"); idx = findFirstRecordLocBySid(SSTRecord.sid) - 1;
if (idx < 0) {
throw new RuntimeException("CountryRecord or SSTRecord not found");
}
} }
_workbookRecordList.add(idx + 1, _externSheetRecord); _workbookRecordList.add(idx + 1, _externSheetRecord);
_workbookRecordList.add(idx + 1, supbook); _workbookRecordList.add(idx + 1, supbook);

View File

@ -59,7 +59,6 @@ import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.CommonObjectDataSubRecord; import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord; import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord;
import org.apache.poi.hssf.record.NameRecord; import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.TabIdRecord; import org.apache.poi.hssf.record.TabIdRecord;
import org.apache.poi.hssf.record.UnknownRecord; import org.apache.poi.hssf.record.UnknownRecord;
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate; import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
@ -2887,6 +2886,11 @@ public final class TestBugs extends BaseTestBugzillaIssues {
} }
} }
@Test
public void test55505() throws IOException {
simpleTest("bug55505.xls");
}
@Test @Test
public void test63940() throws IOException { public void test63940() throws IOException {
simpleTest("SUBSTITUTE.xls"); simpleTest("SUBSTITUTE.xls");
@ -2910,6 +2914,11 @@ public final class TestBugs extends BaseTestBugzillaIssues {
HSSFRow r = s.createRow(10_000); HSSFRow r = s.createRow(10_000);
HSSFCell c = r.createCell(0); HSSFCell c = r.createCell(0);
c.setCellValue(10); c.setCellValue(10);
HSSFSheet tmpSheet = wb1.createSheet("POITESTSHEET");
tmpSheet.createRow(10).createCell(10).setCellValue("Test");
wb1.removeSheetAt(wb1.getSheetIndex(tmpSheet));
simpleTestHelper(wb1, fileName); simpleTestHelper(wb1, fileName);
try (HSSFWorkbook wb2 = writeOutAndReadBack(wb1)) { try (HSSFWorkbook wb2 = writeOutAndReadBack(wb1)) {

Binary file not shown.