Bug 47460 - XFFSWorkbook Core Properties initialization
Summary: XFFSWorkbook Core Properties initialization
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.5-dev
Hardware: PC Mac OS X 10.4
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-30 08:58 UTC by Roberto Manicardi
Modified: 2009-07-12 01:22 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roberto Manicardi 2009-06-30 08:58:43 UTC
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?
Comment 1 Yegor Kozlov 2009-07-12 01:22:01 UTC
Fixed in r793291

Regards,
Yegor