List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook getDocumentSummaryInformation
public DocumentSummaryInformation getDocumentSummaryInformation()
From source file:edu.casetools.rcase.extensions.excel.control.Exporter.java
License:Open Source License
private void setDefaultProperties(String templateName) { HSSFWorkbook hworkbook = (HSSFWorkbook) this.workbook; hworkbook.createInformationProperties(); SummaryInformation si = hworkbook.getSummaryInformation(); DocumentSummaryInformation dsi = hworkbook.getDocumentSummaryInformation(); si.setAuthor(I18nMessageService.getString("Excel.Author")); dsi.setCompany(I18nMessageService.getString("Excel.Company")); si.setApplicationName(I18nMessageService.getString("Excel.Application")); org.apache.poi.hpsf.CustomProperties cp = dsi.getCustomProperties(); cp.put("Table Template", templateName); dsi.setCustomProperties(cp);// www . j a v a 2 s . c om }
From source file:lucee.runtime.poi.Excel.java
License:Open Source License
public Struct getSummaryInfo() { Struct infostruct = new StructImpl(); int sheets = workbook.getNumberOfSheets(); infostruct.setEL("SHEETS", new Double(sheets)); if (sheets > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < sheets; i++) { if (i > 0) sb.append(','); sb.append(workbook.getSheetName(i)); }//from w ww . ja v a 2s . c om infostruct.setEL("SHEETNAMES", sb.toString()); } if (xmlFormat == FORMAT_HSSF) { infostruct.setEL("SPREADSHEETTYPE", "Excel"); HSSFWorkbook hssfworkbook = (HSSFWorkbook) workbook; info(infostruct, hssfworkbook.getSummaryInformation()); info(infostruct, hssfworkbook.getDocumentSummaryInformation()); } else if (xmlFormat == FORMAT_XSSF) { infostruct.put("SPREADSHEETTYPE", "Excel (2007)"); XSSFWorkbook xssfworkbook = (XSSFWorkbook) workbook; POIXMLProperties props = xssfworkbook.getProperties(); info(infostruct, props.getCoreProperties().getUnderlyingProperties()); info(infostruct, props.getExtendedProperties().getUnderlyingProperties()); } return infostruct; }
From source file:org.alanwilliamson.openbd.plugin.spreadsheet.functions.SpreadsheetAddInfo.java
License:Open Source License
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(); /*//from w w w . j a v a 2 s . com * 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; }
From source file:org.alanwilliamson.openbd.plugin.spreadsheet.functions.SpreadsheetInfo.java
License:Open Source License
public cfData execute(cfSession _session, List<cfData> parameters) throws cfmRunTimeException { cfSpreadSheetData spreadsheet = null; spreadsheet = (cfSpreadSheetData) parameters.get(0); Workbook workbook = spreadsheet.getWorkBook(); cfStructData s = new cfStructData(); /*/* www. j a v a 2 s . c o m*/ * Sheet details */ s.setData("sheets", new cfNumberData(workbook.getNumberOfSheets())); cfArrayData sheetArr = cfArrayData.createArray(1); for (int x = 0; x < workbook.getNumberOfSheets(); x++) { String name = workbook.getSheetName(x); if (name == null) name = ""; sheetArr.addElement(new cfStringData(name)); } s.setData("sheetnames", sheetArr); /* * Workbook type */ if (workbook instanceof XSSFWorkbook) { s.setData("spreadsheettype", new cfStringData("xlsx")); } else { s.setData("spreadsheettype", new cfStringData("xls")); } /* * XSSFWorkbook */ if (workbook instanceof XSSFWorkbook) { XSSFWorkbook xSSFWorkbook = (XSSFWorkbook) workbook; CoreProperties cP = xSSFWorkbook.getProperties().getCoreProperties(); s.setData("category", new cfStringData(cP.getCategory())); s.setData("subject", new cfStringData(cP.getSubject())); s.setData("title", new cfStringData(cP.getTitle())); s.setData("revision", new cfStringData(cP.getRevision())); s.setData("author", new cfStringData(cP.getCreator())); s.setData("description", new cfStringData(cP.getDescription())); if (cP.getLastPrinted() != null) s.setData("lastprinted", new cfDateData(cP.getLastPrinted())); if (cP.getModified() != null) s.setData("lastsaved", new cfDateData(cP.getModified())); if (cP.getCreated() != null) s.setData("creationdate", new cfDateData(cP.getCreated())); } else { HSSFWorkbook hSSFWorkbook = (HSSFWorkbook) workbook; DocumentSummaryInformation dSummary = hSSFWorkbook.getDocumentSummaryInformation(); if (dSummary == null) { s.setData("category", cfStringData.EMPTY_STRING); s.setData("company", cfStringData.EMPTY_STRING); s.setData("manager", cfStringData.EMPTY_STRING); } else { s.setData("category", new cfStringData(dSummary.getCategory())); s.setData("company", new cfStringData(dSummary.getCompany())); s.setData("manager", new cfStringData(dSummary.getManager())); } SummaryInformation sInformation = hSSFWorkbook.getSummaryInformation(); if (sInformation == null) { s.setData("author", cfStringData.EMPTY_STRING); s.setData("comments", cfStringData.EMPTY_STRING); s.setData("keywords", cfStringData.EMPTY_STRING); s.setData("lastauthor", cfStringData.EMPTY_STRING); s.setData("title", cfStringData.EMPTY_STRING); s.setData("subject", cfStringData.EMPTY_STRING); } else { s.setData("author", new cfStringData(sInformation.getAuthor())); s.setData("comments", new cfStringData(sInformation.getComments())); s.setData("keywords", new cfStringData(sInformation.getKeywords())); s.setData("lastauthor", new cfStringData(sInformation.getLastAuthor())); s.setData("title", new cfStringData(sInformation.getTitle())); s.setData("subject", new cfStringData(sInformation.getSubject())); if (sInformation.getCreateDateTime() != null) s.setData("creationdate", new cfDateData(sInformation.getCreateDateTime())); if (sInformation.getLastSaveDateTime() != null) s.setData("lastsaved", new cfDateData(sInformation.getLastSaveDateTime())); if (sInformation.getLastPrinted() != null) s.setData("lastprinted", new cfDateData(sInformation.getLastPrinted())); } } return s; }
From source file:org.eclipse.scada.ae.ui.views.export.excel.impl.ExportEventsImpl.java
License:Open Source License
private void makeDocInfo(final HSSFWorkbook workbook) { workbook.createInformationProperties(); final DocumentSummaryInformation dsi = workbook.getDocumentSummaryInformation(); dsi.setCompany("Eclipse SCADA Project"); final CustomProperties cp = new CustomProperties(); cp.put("Eclipse SCADA Export Version", Activator.getDefault().getBundle().getVersion().toString()); dsi.setCustomProperties(cp);//from ww w .j a va2s .c o m }
From source file:org.openscada.ae.ui.views.export.excel.impl.ExportEventsImpl.java
License:Open Source License
private void makeDocInfo(final HSSFWorkbook workbook) { workbook.createInformationProperties(); final DocumentSummaryInformation dsi = workbook.getDocumentSummaryInformation(); dsi.setCompany("TH4 SYSTEMS GmbH"); final CustomProperties cp = new CustomProperties(); cp.put("openSCADA Export Version", Activator.getDefault().getBundle().getVersion().toString()); dsi.setCustomProperties(cp);/* ww w . ja va2 s . c o m*/ }
From source file:rocky.sizecounter.SizeCounterUtil.java
License:Apache License
/** * Count size of Excel file./* ww w . j av a 2 s . co m*/ * * @param filePath path of Excel file * @return SizeMetaData: Unit,Size: SHEET; Unit1,Size1:PAGE */ public static SizeMetaData countSpreadSheet(String filePath) { InputStream is = null; SizeMetaData sizeMD = new SizeMetaData(); int nmPage = 0; int nmSheet; try { is = CommonUtil.loadResource(filePath); if (CommonUtil.getExtension(filePath).equals("xls")) { HSSFWorkbook wb = new HSSFWorkbook(is); wb.getDocumentSummaryInformation().getLineCount(); nmSheet = wb.getNumberOfSheets(); HSSFSheet sheet; for (int i = 0; i < wb.getNumberOfSheets(); i++) { sheet = wb.getSheetAt(i); // Count approximately number of page nmPage += sheet.getPrintSetup().getFitWidth() + sheet.getPrintSetup().getFitHeight(); } sizeMD.setUnit(UnitType.SHEET); sizeMD.setSize(nmSheet); sizeMD.setUnit1(UnitType.PAGE); sizeMD.setSize1(nmPage); } else if (CommonUtil.getExtension(filePath).equals("xlsx")) { XSSFWorkbook xwb = new XSSFWorkbook(is); nmSheet = xwb.getNumberOfSheets(); XSSFSheet sheet; for (int i = 0; i < xwb.getNumberOfSheets(); i++) { sheet = xwb.getSheetAt(i); // Count approximately number of page nmPage += sheet.getPrintSetup().getFitWidth() + sheet.getPrintSetup().getFitHeight(); } sizeMD.setUnit(UnitType.SHEET); sizeMD.setSize(nmSheet); sizeMD.setUnit1(UnitType.PAGE); sizeMD.setSize1(nmPage); } } catch (FileNotFoundException ex) { LOG.warn("Invalid when reading file.", ex); } catch (IOException ex) { LOG.warn("Invalid when reading file.", ex); } catch (Exception e) { LOG.warn("Can not count file " + new File(filePath).getName(), e); } finally { if (is != null) { try { is.close(); } catch (IOException ex) { LOG.warn("Close the file input stream", ex); } } } return sizeMD; }
From source file:se.mithlond.services.content.impl.ejb.report.ExcelReportServiceBean.java
License:Apache License
/** * {@inheritDoc}// w ww . j a v a 2 s .com */ @Override public Workbook createDocument(@NotNull final Membership activeMembership, @NotNull final String title) { // Check sanity Validate.notNull(activeMembership, "activeMembership"); final HSSFWorkbook toReturn = new HSSFWorkbook(); toReturn.createInformationProperties(); // Add some comments. final SummaryInformation summaryInformation = toReturn.getSummaryInformation(); summaryInformation.setCreateDateTime(new Date()); summaryInformation.setTitle(title); summaryInformation.setAuthor("Nazgl Services Excel Report Generator"); summaryInformation.setSubject("Requested by: " + activeMembership.getAlias()); summaryInformation.setRevNumber("1"); // Add some Document summary information as well. final DocumentSummaryInformation documentSummaryInformation = toReturn.getDocumentSummaryInformation(); final String orgName = activeMembership.getOrganisation().getOrganisationName(); documentSummaryInformation.setCompany(activeMembership.getOrganisation().getOrganisationName()); documentSummaryInformation.setManager(orgName + " is Da Boss of you!"); // All Done. return toReturn; }