I had a similar question to yours, but I was waiting until you finished your research so I didn't confuse matters.

Just to ensure that I understand your conclusion, I have no way to determine the style and then apply it to a number field while reading a spreadsheet.

Correct?

Thanks
Tony

On Sep 12, 2008, at 10:56 AM, Axel Rose wrote:

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);


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to