XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
StylesSource ss = workbook.getStylesSource();
assertNotNull(ss);
assertTrue(ss instanceof StylesTable);
StylesTable st = (StylesTable)ss;
// Has 8 number formats
assertEquals(8, st._getNumberFormatSize());
// Has 2 fonts
assertEquals(2, st._getFontsSize());
// Has 2 fills
assertEquals(2, st._getFillsSize());
// Has 1 border
assertEquals(1, st._getBordersSize());
// Add two more styles
assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8,
st.putNumberFormat("testFORMAT"));
assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8,
st.putNumberFormat("testFORMAT"));
assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 9,
st.putNumberFormat("testFORMAT2"));
assertEquals(10, st._getNumberFormatSize());
// Save, load back in again, and check
ByteArrayOutputStream baos = new ByteArrayOutputStream();
workbook.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
workbook = new XSSFWorkbook(Package.open(bais));
ss = workbook.getStylesSource();
assertNotNull(ss);
assertTrue(ss instanceof StylesTable);
st = (StylesTable)ss;
assertEquals(10, st._getNumberFormatSize());
assertEquals(2, st._getFontsSize());
assertEquals(2, st._getFillsSize());
assertEquals(1, st._getBordersSize());
}