https://issues.apache.org/bugzilla/show_bug.cgi?id=47540
Summary: Custom properties and Extended properties are not
saved
Product: POI
Version: 3.5-dev
Platform: PC
OS/Version: Mac OS X 10.4
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
AssignedTo: [email protected]
ReportedBy: [email protected]
Custom properties and Extended properties are not saved when I create a new
XSSFWorkbook.
Below you can find one unit test for Extended properties and one for Custom
properties
public void testWorkbookExtendedProperties() throws Exception {
XSSFWorkbook workbook = new XSSFWorkbook();
POIXMLProperties props = workbook.getProperties();
assertNotNull(props);
org.apache.poi.POIXMLProperties.ExtendedProperties properties =
props.getExtendedProperties();
org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTProperties
ctProps = properties.getUnderlyingProperties();
String appVersion = "3.5 beta";
String application = "POI";
ctProps.setApplication(application);
ctProps.setAppVersion(appVersion);
ctProps=null;
properties=null;
props = null;
XSSFWorkbook newWorkbook =
XSSFTestDataSamples.writeOutAndReadBack(workbook);
assertTrue(workbook!=newWorkbook);
POIXMLProperties newProps = newWorkbook.getProperties();
assertNotNull(newProps);
org.apache.poi.POIXMLProperties.ExtendedProperties newProperties =
newProps.getExtendedProperties();
org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTProperties
newCtProps = newProperties.getUnderlyingProperties();
assertEquals(application,newCtProps.getApplication());
assertEquals(appVersion,newCtProps.getAppVersion());
}
public void testWorkbookCustomProperties() throws Exception {
XSSFWorkbook workbook = new XSSFWorkbook();
POIXMLProperties props = workbook.getProperties();
assertNotNull(props);
org.apache.poi.POIXMLProperties.CustomProperties properties =
props.getCustomProperties();
org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties
ctProps = properties.getUnderlyingProperties();
org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty
property = ctProps.addNewProperty();
String fmtid =
"{A1A1A1A1A1A1A1A1-A1A1A1A1-A1A1A1A1-A1A1A1A1-A1A1A1A1A1A1A1A1}";
int pId = 1;
String name = "testProperty";
String stringValue = "testValue";
property.setFmtid(fmtid);
property.setPid(pId);
property.setName(name);
property.setBstr(stringValue);
property =null;
ctProps=null;
properties=null;
props = null;
XSSFWorkbook newWorkbook =
XSSFTestDataSamples.writeOutAndReadBack(workbook);
assertTrue(workbook!=newWorkbook);
POIXMLProperties newProps = newWorkbook.getProperties();
assertNotNull(newProps);
org.apache.poi.POIXMLProperties.CustomProperties newProperties =
newProps.getCustomProperties();
org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties
newCtProps = newProperties.getUnderlyingProperties();
assertEquals(1,newCtProps.getPropertyArray().length);
org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty
newpProperty = newCtProps.getPropertyArray()[0];
assertEquals(fmtid, newpProperty.getFmtid() );
assertEquals(pId,newpProperty.getPid());
assertEquals(name,newpProperty.getName());
assertEquals(stringValue,newpProperty.getBstr());
}
--
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]