Java Code Examples for org.apache.poi.POIXMLProperties.CoreProperties

The following examples show how to use org.apache.poi.POIXMLProperties.CoreProperties. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public cfData execute( cfSession _session, List<cfData> parameters ) throws cfmRunTimeException {
	if ( parameters.get(0).getDataType() != cfData.CFSTRUCTDATA )
		throwException(_session, "parameter must be of type structure");
	
	cfSpreadSheetData	spreadsheet	= (cfSpreadSheetData)parameters.get(1);
	cfStructData	s	= (cfStructData)parameters.get(0);
	
	Workbook	workbook	= spreadsheet.getWorkBook();
	
	/*
	 * XSSFWorkbook
	 */
	if ( workbook instanceof XSSFWorkbook ){
		XSSFWorkbook xSSFWorkbook = (XSSFWorkbook)workbook;
		
		CoreProperties cP = xSSFWorkbook.getProperties().getCoreProperties();
		
		if ( s.containsKey("author") )
			cP.setCreator( s.getData("author").getString() );
		if ( s.containsKey("category") )
			cP.setCategory( s.getData("category").getString() );
		if ( s.containsKey("subject") )
			cP.setSubjectProperty( s.getData("subject").getString() );
		if ( s.containsKey("title") )
			cP.setTitle( s.getData("title").getString() );
		if ( s.containsKey("revision") )
			cP.setRevision( s.getData("revision").getString() );
		if ( s.containsKey("description") )
			cP.setDescription( s.getData("description").getString() );
		 		
	}else{
		HSSFWorkbook hSSFWorkbook = (HSSFWorkbook)workbook;
		DocumentSummaryInformation dSummary = hSSFWorkbook.getDocumentSummaryInformation();
		
		if ( dSummary == null ){
			hSSFWorkbook.createInformationProperties();
			dSummary = hSSFWorkbook.getDocumentSummaryInformation();
		}
		
		if ( s.containsKey("category") )
			dSummary.setCategory( s.getData("category").getString() );
		if ( s.containsKey("manager") )
			dSummary.setManager( s.getData("manager").getString() );
		if ( s.containsKey("company") )
			dSummary.setCompany( s.getData("company").getString() );

		SummaryInformation sInformation = hSSFWorkbook.getSummaryInformation();
		
		if ( s.containsKey("title") )
			sInformation.setTitle( s.getData("title").getString() );
		if ( s.containsKey("subject") )
			sInformation.setSubject( s.getData("subject").getString() );
		if ( s.containsKey("author") )
			sInformation.setAuthor( s.getData("author").getString() );
		if ( s.containsKey("comments") )
			sInformation.setComments( s.getData("comments").getString() );
		if ( s.containsKey("keywords") )
			sInformation.setKeywords( s.getData("keywords").getString() );
		if ( s.containsKey("lastauthor") )
			sInformation.setLastAuthor( s.getData("lastauthor").getString() );
	}
	
	return cfBooleanData.TRUE;
}