You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Roberto Manicardi <ro...@gmail.com> on 2009/06/19 11:15:08 UTC
XSSFWorkbook properties
Hi,
I'm new to POI and I'm trying to create a new Spreadsheet document and
set come Core properties (such the author and the title) but I have
some problems.
To show what I'm doing I've created a simple TestCase:
package org.apache.poi.xssf.usermodel;
import org.apache.poi.POIXMLProperties;
import junit.framework.TestCase;
public class TestXSSFProperties extends TestCase {
public void testCreateWorkbookAndSetCoreProperties() throws Exception{
XSSFWorkbook workbook = new XSSFWorkbook();
POIXMLProperties properties = workbook.getProperties();
assertNotNull(properties);
}
}
If I run the testcase (I'm using the trunk version of POI) I have the
following error:
java.lang.IllegalArgumentException: A document must always have core
properties defined!
at org.apache.poi.POIXMLProperties.<init>(POIXMLProperties.java:47)
at org.apache.poi.POIXMLDocument.getProperties(POIXMLDocument.java:162)
at
org
.apache
.poi
.xssf
.usermodel
.TestXSSFProperties
.testCreateWorkbookAndSetCoreProperties(TestXSSFProperties.java:13)
....
I've tried to find a way to set the Core properties object but I
haven't found any useful Java method.
If I create a new Workbook by loading and existing xlsx file it all
works fine but If I create it from scratch the Core Propeties object
is not create.
Is there a way to create the core properties or I have to patch the
XSSFWorkbook constructor? In the second case, it's best to create the
core properties upon creation or to add a createProperties method?
Thanks,
Roberto
--
Roberto Manicardi
=
=
=
========================================================================
http://www.jugroma.it
http://roma.javaday.it
JUG Roma Coordinator