/** * Processes the file and returns the text */ public String GetText() { try { ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(Container); XSSFReader xssfReader = new XSSFReader(Container); StylesTable styles = xssfReader.GetStylesTable(); XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator)xssfReader.GetSheetsData(); StringBuilder text = new StringBuilder(); SheetTextExtractor sheetExtractor = new SheetTextExtractor(text); while (iter.HasNext()) { InputStream stream = iter.next(); if (includeSheetNames) { text.Append(iter.GetSheetName()); text.Append('\n'); } ProcessSheet(sheetExtractor, styles, strings, stream); stream.Close(); } return(text.ToString()); } catch (IOException e) { System.err.println(e); return(null); } catch (OpenXML4NetException o4je) { System.err.println(o4je); return(null); } }
/** * Processes the file and returns the text */ public String GetText() { try { ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(Container); XSSFReader xssfReader = new XSSFReader(Container); StylesTable styles = xssfReader.GetStylesTable(); XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator)xssfReader.GetSheetsData(); StringBuilder text = new StringBuilder(); SheetTextExtractor sheetExtractor = new SheetTextExtractor(text); while (iter.HasNext()) { InputStream stream = iter.next(); if (includeSheetNames) { text.Append(iter.GetSheetName()); text.Append('\n'); } ProcessSheet(sheetExtractor, styles, strings, stream); stream.Close(); } return text.ToString(); } catch (IOException e) { System.err.println(e); return null; } catch (OpenXML4NetException o4je) { System.err.println(o4je); return null; } }