https://issues.apache.org/bugzilla/show_bug.cgi?id=51955

             Bug #: 51955
           Summary: unable to get themes table from getStylesTable() call
                    using the XSSFReader event model
           Product: POI
           Version: 3.8-dev
          Platform: All
        OS/Version: Windows XP
            Status: NEW
          Severity: critical
          Priority: P2
         Component: XSSF
        AssignedTo: [email protected]
        ReportedBy: [email protected]
    Classification: Unclassified


Created attachment 27690
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27690
Sample xlsx file to demonstrate the bug

I am trying to get the themes table for XLSX files using the XSSFReader event
model API (3.8-beta4). Unfortunately the getStylesTable() call of the
XSSFReader class always returns a StylesTable with a null theme. Please see the
following code and the attached xlsx file that demonstrate this problem. 

On the other hand, using the user model XSSFWorkbook API I am able to get the
themes table and the RGB values correctly. So I suspect this is a bug of the
getStylesTable() method.


package org.apache.poi.ss.examples;

import java.io.FileInputStream;

import org.apache.poi.xssf.eventusermodel.XSSFReader;
import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.model.ThemesTable;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.openxml4j.opc.OPCPackage;

public class TestTheme {

    public void processEventModel(String filename) throws Exception {
        OPCPackage pkg = OPCPackage.open(filename);
        XSSFReader r = new XSSFReader( pkg );
        StylesTable st = r.getStylesTable();
        ThemesTable ttable = st.getTheme();
        System.out.println(ttable);

        XSSFCellStyle cs = st.getStyleAt(1);
        System.out.println(cs.getFillForegroundColorColor().getARGBHex());
    }

    public void processUserModel(String filename) throws Exception {
           OPCPackage pkg = OPCPackage.open(filename);
        XSSFWorkbook wb = new XSSFWorkbook(pkg);
        StylesTable st = wb.getStylesSource(); 
        ThemesTable ttable = st.getTheme();

        System.out.println(ttable);
        XSSFCellStyle cs = st.getStyleAt(1);
        System.out.println(cs.getFillForegroundColorColor().getARGBHex());
    }

    public static void main(String[] args) throws Exception {
        TestTheme tt = new TestTheme();
        System.out.println("Getting ThemesTable using Event Model");
        tt.processEventModel(args[0]);
        System.out.println("Getting ThemesTable using User Model");
        tt.processUserModel(args[0]);
    }
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to