Add reproducer for Bug 57165, no fix yet, though...

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1647265 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2014-12-22 09:10:01 +00:00
parent 0fdfac62c9
commit 2d07fa94af

View File

@ -32,6 +32,7 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.SXSSFITestDataProvider; import org.apache.poi.xssf.SXSSFITestDataProvider;
import org.apache.poi.xssf.XSSFTestDataSamples; import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.junit.Test;
/** /**
* @author centic * @author centic
@ -134,4 +135,36 @@ public final class TestUnfixedBugs extends TestCase {
} }
} }
} }
@Test
public void test57165() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
try {
removeAllSheetsBut(3, wb);
wb.cloneSheet(0); // Throws exception here
wb.setSheetName(1, "New Sheet");
//saveWorkbook(wb, fileName);
XSSFWorkbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
try {
} finally {
wbBack.close();
}
} finally {
wb.close();
}
}
private static void removeAllSheetsBut(int sheetIndex, Workbook wb)
{
int sheetNb = wb.getNumberOfSheets();
// Move this sheet at the first position
wb.setSheetOrder(wb.getSheetName(sheetIndex), 0);
for (int sn = sheetNb - 1; sn > 0; sn--)
{
wb.removeSheetAt(sn);
}
}
} }