List of usage examples for org.apache.poi.hssf.extractor ExcelExtractor setIncludeSheetNames
@Override
public void setIncludeSheetNames(boolean includeSheetNames)
From source file:com.bayareasoftware.chartengine.ds.util.ExcelDump.java
License:Apache License
private static void runNew(String fileName) throws Exception { InputStream inp = new FileInputStream(fileName); HSSFWorkbook wb = new HSSFWorkbook(new POIFSFileSystem(inp)); ExcelExtractor xt = new ExcelExtractor(wb); xt.setFormulasNotResults(false);// ww w. ja v a2 s. c o m xt.setIncludeBlankCells(true); xt.setIncludeSheetNames(false); String text = xt.getText(); String[] lines = StringUtil.splitCompletely(text, '\n'); for (int i = 0; i < lines.length; i++) { System.out.println((i + 1) + ") " + lines[i]); } System.out.println("XLS: \n" + text); }
From source file:com.frameworkset.platform.cms.searchmanager.extractors.CmsExtractorMsExcel.java
License:Open Source License
/** * ?excel2003 //from www . j a v a 2 s .c o m * @param path * @return * @throws IOException */ public String readExcel(InputStream in) throws IOException { String content = null; try { HSSFWorkbook wb = new HSSFWorkbook(in); ExcelExtractor extractor = new ExcelExtractor(wb); extractor.setFormulasNotResults(true); extractor.setIncludeSheetNames(false); content = extractor.getText(); this.m_documentSummary = extractor.getDocSummaryInformation(); this.m_summary = extractor.getSummaryInformation(); } catch (FileNotFoundException e) { e.printStackTrace(); } return content; }
From source file:it.smartcommunitylab.riciclo.app.importer.converter.DataImporter.java
License:Apache License
private Rifiuti readExcel(InputStream inp) throws Exception { HSSFWorkbook wb = new HSSFWorkbook(new POIFSFileSystem(inp)); ExcelExtractor extractor = new ExcelExtractor(wb); extractor.setFormulasNotResults(true); extractor.setIncludeSheetNames(false); Rifiuti rifiuti = new Rifiuti(); Set<String> sheetNames = Sets.newHashSet(); for (int i = 0; i < wb.getNumberOfSheets(); i++) { sheetNames.add(wb.getSheetAt(i).getSheetName()); }//from w w w. j a v a 2 s.c o m Set missingExpected = Sets.newHashSet(expectedSheets); missingExpected.removeAll(sheetNames); Set additionalFound = Sets.newHashSet(sheetNames); additionalFound.removeAll(expectedSheets); if (!missingExpected.isEmpty() || !additionalFound.isEmpty()) { throw new ImportError(Lists.newArrayList("Missing sheet(s) expected: " + missingExpected, "Additional sheet(s) found: " + additionalFound)); } for (int i = 0; i < wb.getNumberOfSheets(); i++) { Sheet sheet = wb.getSheetAt(i); Thread.sleep(500); // System.out.println(sheet.getSheetName()); // if (sheet.getRow(0).getLastCellNum() == 1 && !oneColumnAsMany.contains(sheet.getSheetName())) { // } else { { System.err.println(">" + sheet.getSheetName()); List<Map<String, String>> result = getSheetMap(sheet); mapMap(rifiuti, sheet.getSheetName(), result); } } completePuntiRaccolta(rifiuti); return rifiuti; }
From source file:it.smartcommunitylab.ungiorno.importer.Importer.java
License:Apache License
private HSSFWorkbook readFile(InputStream inp, Set<String> expected) throws IOException, ImportError { HSSFWorkbook wb = new HSSFWorkbook(new POIFSFileSystem(inp)); ExcelExtractor extractor = new ExcelExtractor(wb); extractor.setFormulasNotResults(true); extractor.setIncludeSheetNames(false); Set<String> sheetNames = Sets.newHashSet(); for (int i = 0; i < wb.getNumberOfSheets(); i++) { sheetNames.add(wb.getSheetAt(i).getSheetName()); }//from w ww . j a v a 2 s .c o m Set<String> missingExpected = new HashSet<String>(expected); missingExpected.removeAll(sheetNames); Set<String> additionalFound = Sets.newHashSet(sheetNames); additionalFound.removeAll(expected); if (!missingExpected.isEmpty() || !additionalFound.isEmpty()) { System.err.println("Missing sheet(s) expected: " + missingExpected + " - Additional sheet(s) found: " + additionalFound); throw new ImportError(Lists.newArrayList("Missing sheet(s) expected: " + missingExpected, "Additional sheet(s) found: " + additionalFound)); } return wb; }