Java Code Examples for org.apache.poi.xssf.eventusermodel.XSSFReader#getWorkbookData()
The following examples show how to use
org.apache.poi.xssf.eventusermodel.XSSFReader#getWorkbookData() .
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
Source File: XlsxSaxAnalyser.java From easyexcel with Apache License 2.0 | 5 votes |
private void analysisUse1904WindowDate(XSSFReader xssfReader, XlsxReadWorkbookHolder xlsxReadWorkbookHolder) throws Exception { if (xlsxReadWorkbookHolder.globalConfiguration().getUse1904windowing() != null) { return; } InputStream workbookXml = xssfReader.getWorkbookData(); WorkbookDocument ctWorkbook = WorkbookDocument.Factory.parse(workbookXml); CTWorkbook wb = ctWorkbook.getWorkbook(); CTWorkbookPr prefix = wb.getWorkbookPr(); if (prefix != null && prefix.getDate1904()) { xlsxReadWorkbookHolder.getGlobalConfiguration().setUse1904windowing(Boolean.TRUE); } else { xlsxReadWorkbookHolder.getGlobalConfiguration().setUse1904windowing(Boolean.FALSE); } }
Example 2
Source File: StAXBasedParser.java From dremio-oss with Apache License 2.0 | 5 votes |
/** * Create instance * @param inputStream sheet input stream * @param pluginConfig config options * @param writer {@link VectorContainerWriter} for writing values into vectors. * @param managedBuf Workspace buffer. * @param maxCellSize maximum allowable size of variable length cells */ public StAXBasedParser(final InputStream inputStream, final ExcelFormatPluginConfig pluginConfig, final VectorContainerWriter writer, final ArrowBuf managedBuf, final HashSet<String> columnsToProject, final int maxCellSize) throws Exception { pkgInputStream = OPCPackage.open(inputStream); this.writer = writer.rootAsStruct(); this.managedBuf = managedBuf; this.maxCellSize = maxCellSize; final XSSFReader xssfReader = new XSSFReader(pkgInputStream); // Find the sheet id of the given sheet name in workbook try (final InputStream wbInputStream = xssfReader.getWorkbookData()) { final String sheetId = ExcelUtil.getSheetId(wbInputStream, pluginConfig.sheet); if (sheetId == null) { throw new SheetNotFoundException(); } // Open the InputStream for sheet sheetInputStream = xssfReader.getSheet(sheetId); } // WARNING: XSSFReader can actually return null instances of sst and styles sst = xssfReader.getSharedStringsTable(); styles = checkNotNull(xssfReader.getStylesTable(), "Expected a valid styles table instance"); init(pluginConfig.extractHeader, pluginConfig.hasMergedCells); this.columnsToProject = columnsToProject; }
Example 3
Source File: SpreadsheetUtils.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 5 votes |
/** * Checks the source for 1904 windowing flag. This is kind of ugly, but there doesn't seem to be a better way. * Method for event model. * @param reader * @return true if 1904 windowing is used, false otherwise * @throws IOException * @throws XmlException * @throws InvalidFormatException */ public static boolean get1904Windowing(XSSFReader reader) throws IOException, XmlException, InvalidFormatException { InputStream workbookXML = reader.getWorkbookData(); WorkbookDocument doc = WorkbookDocument.Factory.parse(workbookXML); CTWorkbookPr workbookPr = doc.getWorkbook().getWorkbookPr(); boolean windowing1904 = false; if (workbookPr != null) { windowing1904 = workbookPr.getDate1904(); } workbookXML.close(); return windowing1904; }