use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont 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();
}
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.
the class TestXSSFFont method testFamily.
@Test
public void testFamily() {
CTFont ctFont = CTFont.Factory.newInstance();
CTIntProperty family = ctFont.addNewFamily();
family.setVal(FontFamily.MODERN.getValue());
ctFont.setFamilyArray(0, family);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(FontFamily.MODERN.getValue(), xssfFont.getFamily());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.
the class TestXSSFFont method testFontHeight.
@Test
public void testFontHeight() {
CTFont ctFont = CTFont.Factory.newInstance();
CTFontSize size = ctFont.addNewSz();
size.setVal(11);
ctFont.setSzArray(0, size);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(11, xssfFont.getFontHeightInPoints());
xssfFont.setFontHeight(20);
assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.
the class TestXSSFFont method testThemeColor.
@Test
public void testThemeColor() {
CTFont ctFont = CTFont.Factory.newInstance();
CTColor color = ctFont.addNewColor();
color.setTheme(1);
ctFont.setColorArray(0, color);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(ctFont.getColorArray(0).getTheme(), xssfFont.getThemeColor());
xssfFont.setThemeColor(IndexedColors.RED.getIndex());
assertEquals(IndexedColors.RED.getIndex(), ctFont.getColorArray(0).getTheme());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.
the class TestXSSFFont method testBold.
@Test
public void testBold() {
CTFont ctFont = CTFont.Factory.newInstance();
CTBooleanProperty bool = ctFont.addNewB();
bool.setVal(false);
ctFont.setBArray(0, bool);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(false, xssfFont.getBold());
xssfFont.setBold(true);
assertEquals(ctFont.sizeOfBArray(), 1);
assertEquals(true, ctFont.getBArray(0).getVal());
}
Aggregations