use of org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontImpl in project poi by apache.
the class TestXSSFBugs method saveAndReloadReport.
private void saveAndReloadReport(Workbook wb, File outFile) throws IOException {
// run some method on the font to verify if it is "disconnected" already
//for(short i = 0;i < 256;i++)
{
Font font = wb.getFontAt((short) 0);
if (font instanceof XSSFFont) {
XSSFFont xfont = (XSSFFont) wb.getFontAt((short) 0);
CTFontImpl ctFont = (CTFontImpl) xfont.getCTFont();
assertEquals(0, ctFont.sizeOfBArray());
}
}
FileOutputStream fileOutStream = new FileOutputStream(outFile);
try {
wb.write(fileOutStream);
} finally {
fileOutStream.close();
}
FileInputStream is = new FileInputStream(outFile);
try {
Workbook newWB = null;
try {
if (wb instanceof XSSFWorkbook) {
newWB = new XSSFWorkbook(is);
} else if (wb instanceof HSSFWorkbook) {
newWB = new HSSFWorkbook(is);
} else if (wb instanceof SXSSFWorkbook) {
newWB = new SXSSFWorkbook(new XSSFWorkbook(is));
} else {
throw new IllegalStateException("Unknown workbook: " + wb);
}
assertNotNull(newWB.getSheet("test"));
} finally {
if (newWB != null) {
newWB.close();
}
}
} finally {
is.close();
}
}
Aggregations