Bug 47460

Summary: XFFSWorkbook Core Properties initialization
Product: POI Reporter: Roberto Manicardi <roberto.manicardi>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.5-dev   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X 10.4   

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