mirror of https://github.com/apache/poi.git
[bug-69021] add guard around cast
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1917779 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
48305903b3
commit
af5d4b9f22
|
@ -1075,12 +1075,15 @@ public final class InternalWorkbook {
|
|||
// Ensure we have enough tab IDs
|
||||
// Can be a few short if new sheets were added
|
||||
if (records.getTabpos() > 0) {
|
||||
TabIdRecord tir = ( TabIdRecord ) records.get(records.getTabpos());
|
||||
Record rec = records.get(records.getTabpos());
|
||||
if (rec instanceof TabIdRecord) {
|
||||
TabIdRecord tir = ( TabIdRecord ) rec;
|
||||
if(tir.getTabIdSize() < boundsheets.size()) {
|
||||
fixTabIdRecord();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
int retval = 0;
|
||||
|
|
|
@ -18,11 +18,32 @@
|
|||
package org.apache.poi.hssf.usermodel;
|
||||
|
||||
import org.apache.poi.hssf.HSSFITestDataProvider;
|
||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||
import org.apache.poi.ss.usermodel.BaseTestSheetShiftRows;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
final class TestHSSFSheetShiftRows extends BaseTestSheetShiftRows {
|
||||
|
||||
public TestHSSFSheetShiftRows() {
|
||||
super(HSSFITestDataProvider.instance);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug69021() throws IOException {
|
||||
try (HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("bug69021.xls")) {
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
int rowIndex = 2;
|
||||
sheet.shiftRows(rowIndex, sheet.getLastRowNum(), 1);
|
||||
Row row = sheet.createRow(rowIndex);
|
||||
row.createCell(0).setCellValue("switch");
|
||||
HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(workbook);
|
||||
assertNotNull(wbBack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue