List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook getSummaryInformation
public SummaryInformation getSummaryInformation()
From source file:com.opendoorlogistics.core.tables.io.PoiIO.java
License:Open Source License
public static boolean exportDatastore(ODLDatastore<? extends ODLTableReadOnly> ds, File file, boolean xlsx, ProcessingApi processing, ExecutionReport report) { //tmpFileBugFix(); Workbook wb = null;// www . ja v a 2s.co m SXSSFWorkbook sxssfwb = null; HSSFWorkbook hssfwb = null; if (xlsx == false) { hssfwb = new HSSFWorkbook(); hssfwb.createInformationProperties(); hssfwb.getSummaryInformation().setAuthor(AppConstants.ORG_NAME); wb = hssfwb; } else { // sxssfwb = new SXSSFWorkbook(100); // keep 100 rows in memory, exceeding rows will be flushed to disk sxssfwb = new SXSSFWorkbook(null, 100, false, true); wb = sxssfwb; // XSSFWorkbook xssfWorkbook = new XSSFWorkbook(); /// POIXMLProperties xmlProps = sxssfwb. //POIXMLProperties.CoreProperties coreProps = xmlProps.getCoreProperties(); // coreProps.setCreator(AppConstants.ORG_NAME); // wb = xssfWorkbook; } try { // save schema addSchema(ds, wb); for (ODLTableDefinition table : TableUtils.getAlphabeticallySortedTables(ds)) { ODLTableReadOnly tro = (ODLTableReadOnly) table; Sheet sheet = wb.createSheet(tro.getName()); if (sheet == null) { return false; } exportTable(sheet, tro, 0, processing, report); if (processing != null && processing.isCancelled()) { return false; } } if (processing != null) { processing.postStatusMessage("Saving whole workbook to disk."); } saveWorkbook(file, wb); } catch (Exception e) { throw new RuntimeException(e); } finally { if (sxssfwb != null) { sxssfwb.dispose(); } if (hssfwb != null) { try { hssfwb.close(); } catch (Exception e2) { // TODO: handle exception } } } return true; }
From source file:com.opendoorlogistics.core.tables.io.PoiIO.java
License:Open Source License
private static String getAuthor(Workbook wb) { if (HSSFWorkbook.class.isInstance(wb)) { HSSFWorkbook hssf = (HSSFWorkbook) wb; SummaryInformation info = hssf.getSummaryInformation(); if (info != null) { return info.getAuthor(); }//from www . java 2 s. c o m } else if (XSSFWorkbook.class.isInstance(wb)) { XSSFWorkbook xssf = (XSSFWorkbook) wb; POIXMLProperties xmlProps = xssf.getProperties(); if (xmlProps != null) { POIXMLProperties.CoreProperties coreProps = xmlProps.getCoreProperties(); if (coreProps != null) { return coreProps.getCreator(); } } } return null; }
From source file:com.report.excel.ExcelToHtmlConverter.java
License:Apache License
public void processWorkbook(HSSFWorkbook workbook) { evaluator = workbook.getCreationHelper().createFormulaEvaluator(); for (int sheetNum = 0; sheetNum < workbook.getNumberOfSheets(); sheetNum++) { HSSFSheet sheet = workbook.getSheetAt(sheetNum); for (Row r : sheet) { for (Cell c : r) { if (c.getCellType() == Cell.CELL_TYPE_FORMULA) { evaluator.evaluateFormulaCell(c); }/*from w w w .j a v a 2s .co m*/ } } } final SummaryInformation summaryInformation = workbook.getSummaryInformation(); if (summaryInformation != null) { processDocumentInformation(summaryInformation); } if (isUseDivsToSpan()) { // prepare CSS classes for later usage this.cssClassContainerCell = htmlDocumentFacade.getOrCreateCssClass(cssClassPrefixCell, "padding:0;margin:0;align:left;vertical-align:top;"); this.cssClassContainerDiv = htmlDocumentFacade.getOrCreateCssClass(cssClassPrefixDiv, "position:relative;"); } for (int s = 0; s < workbook.getNumberOfSheets(); s++) { HSSFSheet sheet = workbook.getSheetAt(s); processSheet(sheet); } htmlDocumentFacade.updateStylesheet(); }
From source file:com.wangzhu.poi.ExcelToHtmlConverter.java
License:Apache License
public void processWorkbook(HSSFWorkbook workbook) { final SummaryInformation summaryInformation = workbook.getSummaryInformation(); if (summaryInformation != null) { this.processDocumentInformation(summaryInformation); }//from w ww . ja v a 2s . c om if (this.isUseDivsToSpan()) { // prepare CSS classes for later usage this.cssClassContainerCell = this.htmlDocumentFacade.getOrCreateCssClass(this.cssClassPrefixCell, "padding:0;margin:0;align:left;vertical-align:top;"); this.cssClassContainerDiv = this.htmlDocumentFacade.getOrCreateCssClass(this.cssClassPrefixDiv, "position:relative;"); } for (int s = 0; s < workbook.getNumberOfSheets(); s++) { HSSFSheet sheet = workbook.getSheetAt(s); this.processSheet(sheet); } this.htmlDocumentFacade.updateStylesheet(); }
From source file:com.xhsoft.framework.common.file.ExcelHandle.java
License:Open Source License
public void setDocInfo(HSSFWorkbook xls) { xls.createInformationProperties(); //? SummaryInformation si = xls.getSummaryInformation(); //si.setTitle(title); //si.setSubject(subject); //si.setComments(comments); //si.setAuthor(author); //si.setApplicationName(appName); }
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);//from ww w .j av a2 s . c o m }
From source file:gov.nih.nci.evs.app.neopl.XLSMetadataUtils.java
License:Open Source License
public static void setAuthor(String filename, String author) { HSSFWorkbook workbook = null; FileInputStream fis = null;// ww w .j av a2 s . co m try { System.out.println(filename); fis = new FileInputStream(filename); workbook = new HSSFWorkbook(fis); workbook.createInformationProperties(); SummaryInformation summaryInfo = workbook.getSummaryInformation(); summaryInfo.setAuthor(author); } catch (Exception ex) { ex.printStackTrace(); } finally { try { fis.close(); } catch (Exception ex) { } } FileOutputStream fos = null; try { fos = new FileOutputStream(new File(filename)); workbook.write(fos); fos.flush(); } catch (Exception ex) { ex.printStackTrace(); } finally { try { fos.close(); System.out.println("Outputfile " + filename + " generated."); } catch (Exception ex) { ex.printStackTrace(); } } }
From source file:gov.nih.nci.evs.app.neopl.XLSXMetadataUtils.java
License:Open Source License
public static void setSummaryData(String filename, String[] keys, String[] values) { String size = getFileSize(filename); FileInputStream stream = null; try {//from ww w . j av a 2s. co m stream = new FileInputStream(new File(filename)); POIFSFileSystem poifs = null; boolean passed = false; try { poifs = new POIFSFileSystem(stream); passed = true; } catch (Exception e) { passed = false; } if (!passed) { setPOISummaryData(filename, keys, values); stream.close(); return; } HSSFWorkbook workbook = null; SummaryInformation summaryInfo = null; FileInputStream fis = null; try { System.out.println(filename); fis = new FileInputStream(filename); workbook = new HSSFWorkbook(fis); summaryInfo = workbook.getSummaryInformation(); if (summaryInfo == null) { workbook.createInformationProperties(); summaryInfo = workbook.getSummaryInformation(); for (int i = 0; i < keys.length; i++) { String key = keys[i]; String value = values[i]; System.out.println(key + " -> " + value); if (key.compareTo(SUMMARY_DATA_AUTHOR) == 0) { summaryInfo.setAuthor(value); } else if (key.compareTo(SUMMARY_DATA_KEYWORDS) == 0) { summaryInfo.setKeywords(value); } else if (key.compareTo(SUMMARY_DATA_TITLE) == 0) { summaryInfo.setTitle(value); } else if (key.compareTo(SUMMARY_DATA_SUBJECT) == 0) { summaryInfo.setSubject(value); } } } } catch (Exception ex) { ex.printStackTrace(); } finally { try { fis.close(); } catch (Exception ex) { } } FileOutputStream fos = null; try { fos = new FileOutputStream(new File(filename)); workbook.write(fos); fos.flush(); } catch (Exception ex) { ex.printStackTrace(); } finally { fos.close(); } } catch (Exception ex) { ex.printStackTrace(); } }
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 .j av a 2s. c o m 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:mat.server.service.impl.XLSGenerator.java
/** Creates the meta data. * /*w w w.j ava 2s .c o m*/ * @param wkbk - HSSFWorkbook. * * * */ public final void createMetaData(final HSSFWorkbook wkbk) { // Author: eMeasureTool, Title: Value Set Export, Subject: Value Set // Export, Keywords: Value Set, OID, Export, Measure, Code, Descriptor wkbk.createInformationProperties(); SummaryInformation si = wkbk.getSummaryInformation(); si.setAuthor(AUTHOR); si.setTitle(TITLE); si.setSubject(SUBJECT); si.setKeywords(KEYWORDS); }