Search in sources :

Example 1 with TableStyleInfo

use of org.apache.poi.ss.usermodel.TableStyleInfo in project poi by apache.

the class TestTableStyles method testCustomStyle.

@Test
public void testCustomStyle() throws Exception {
    XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("tableStyle.xlsx");
    Table table = wb.getTable("Table1");
    assertNotNull("missing table", table);
    TableStyleInfo style = table.getStyle();
    assertNotNull("Missing table style info", style);
    assertNotNull("Missing table style", style.getStyle());
    assertEquals("Wrong name", "TestTableStyle", style.getName());
    assertEquals("Wrong name", "TestTableStyle", style.getStyle().getName());
    DifferentialStyleProvider firstColumn = style.getStyle().getStyle(TableStyleType.firstColumn);
    assertNotNull("no first column style", firstColumn);
    FontFormatting font = firstColumn.getFontFormatting();
    assertNotNull("no first col font", font);
    assertTrue("wrong first col bold", font.isBold());
    wb.close();
}
Also used : Table(org.apache.poi.ss.usermodel.Table) DifferentialStyleProvider(org.apache.poi.ss.usermodel.DifferentialStyleProvider) TableStyleInfo(org.apache.poi.ss.usermodel.TableStyleInfo) FontFormatting(org.apache.poi.ss.usermodel.FontFormatting) Test(org.junit.Test)

Aggregations

DifferentialStyleProvider (org.apache.poi.ss.usermodel.DifferentialStyleProvider)1 FontFormatting (org.apache.poi.ss.usermodel.FontFormatting)1 Table (org.apache.poi.ss.usermodel.Table)1 TableStyleInfo (org.apache.poi.ss.usermodel.TableStyleInfo)1 Test (org.junit.Test)1