Last part in a series of tests to get the named styles ...

I can get the GUI set styles from an existing document (sample code below).
It doesn't help though because POI (checked with source of version
3.1-FINAL)
will not read the "STYLEEXT: Named Cell Style Extension (892h)" record.

There is probably some extra code necessary in StyleRecord.

Thanks for listening

Axel

---
sample code to read available styles

Field formatterField = wb.getClass().getDeclaredField("formatter");
formatterField.setAccessible(true);
HSSFDataFormat formatter = (HSSFDataFormat) formatterField.get(wb);
Field workbookField = formatter.getClass().getDeclaredField("workbook");
workbookField.setAccessible(true);
Workbook workbook = (Workbook) workbookField.get(formatter);
List records = workbook.getRecords();
for (int k = 0; k < records.size(); k++) {
    Object o = records.get(k);
    // System.err.println("### class: " + o.getClass().getSimpleName());
    if (o.getClass().getSimpleName().equals("StyleRecord")) {
        StyleRecord styleRecord = (StyleRecord) o;
        if (styleRecord.getType() == 0) { // only GUI styles
            System.err.print(styleRecord);
            System.err.println("### styleRecord.getIndex(): " +
styleRecord.getIndex());
            System.err.println("### styleRecord.getName(): " +
styleRecord.getName());
        }
    }
}
System.err.println("--------------------------------------------");
workbookField.setAccessible(false);
formatterField.setAccessible(false);

Reply via email to