Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Piotr

Thread: create Theme in new XSSFWorkbook

  1. #1
    Piotr is offline Member
    Join Date
    Jul 2015
    Posts
    3
    Rep Power
    0

    Default create Theme in new XSSFWorkbook

    Is it is possible to create empty Theme if I create XSSFWorkbook by constructor XSSFWorkbook()?
    I tried to do this, but there is a lot of fields (like Relations) to fill when I create Theme - and finally I have to do something like reading inputStream. But I donít have IS, because I want create new workbook and fill everything using data from external JSON file.
    Creating Theme is so complicated, so I tried to do this in some other ways too:
    1) I tried to: import empty XLSX file to ApachePOI, get Theme from it and set this Theme to my new XSSFWorkbook. But then my new XLSX file doesnít have file /xl/theme/theme1.xmland informations:
    Java Code:
    <Override ContentType="application/vnd.openxmlformats-officedocument.theme+xml" PartName="/xl/theme/theme1.xml" />
    in content_types.xml,
    Java Code:
    <Override ContentType="application/vnd.openxmlformats-officedocument.theme+xml" PartName="/xl/theme/theme1.xml" />
    in /xl/_rels/workbook.xml.rels.
    2) Then I tried to not create new XSSFWorkbook, but: import external XLSX file, change its Theme and save again as XLSX. Then file has informations about Theme, but about original - not changed.
    I checked that constructor XSSFWorkbook() creates objects like StylesSource and SharedStringsTable, but not ThemesTable. So maybe ití impossible to change Theme after constructor, because in fact it changes nothing?
    Any suggestions? Please, help, Iíve been trying for 3 days.

  2. #2
    Piotr is offline Member
    Join Date
    Jul 2015
    Posts
    3
    Rep Power
    0

    Default Re: create Theme in new XSSFWorkbook

    After some days I can create new Theme without reading anything from external file. I can create two entries in files content_types.xml and /xl/_rels/workbook.xml.rels:
    Java Code:
    XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
    POIXMLDocumentPart docThemePart = xssfWorkbook.createRelationship(XSSFRelation.THEME, XSSFFactory.getInstance(), 1);
    Normally itís not possible in ApachePOI, because it causes error. I had to MODIFY(!) ApachePOI ThemesTable class - I added constructor:
    Java Code:
    public ThemesTable() { super(); }
    Then function above creates file /xl/theme/theme1.xml too, but itís empty. How to fill this file? If I get Theme
    Java Code:
    ThemesTable theme = (ThemesTable) docThemePart;
    and change it, content is not wrote to theme.xml. How to fill this file?
    I checked Zip creating. Method marshall() in ZipPartMarshaller class gets input stream from some workbook parts. And for Theme input stream is empty. Maybe thatís the problem? When I tried (for tests) to create other object:
    Java Code:
    xssfWorkbook.createRelationship(XSSFRelation.CHART, XSSFFactory.getInstance());
    everything was good.
    What to do now?

  3. #3
    Piotr is offline Member
    Join Date
    Jul 2015
    Posts
    3
    Rep Power
    0

Similar Threads

  1. Eclispe color theme problem
    By Aboogesnickle in forum Eclipse
    Replies: 3
    Last Post: 07-23-2014, 10:00 PM
  2. Replies: 3
    Last Post: 06-09-2014, 01:04 PM
  3. How to copy cell styles in an XSSFWorkbook?
    By laredotornado in forum Apache POI
    Replies: 2
    Last Post: 04-03-2012, 05:36 PM
  4. How to change SWT/JFace theme
    By sivakrishnain in forum SWT / JFace
    Replies: 0
    Last Post: 07-28-2010, 06:29 PM
  5. theme while running
    By pgag45 in forum NetBeans
    Replies: 4
    Last Post: 04-20-2009, 04:33 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •