public static Workbook createWorkBook(InputStream templateInputStream, ExcelTypeEnum excelType) throws IOException { Workbook workbook; if (ExcelTypeEnum.XLS.equals(excelType)) { workbook = (templateInputStream == null) ? new HSSFWorkbook() : new HSSFWorkbook( new POIFSFileSystem(templateInputStream)); } else { workbook = (templateInputStream == null) ? new SXSSFWorkbook(500) : new SXSSFWorkbook( new XSSFWorkbook(templateInputStream)); } return workbook; }
public VBAMacroReader(File file) throws IOException { try { this.fs = new POIFSFileSystem(file); } catch (OfficeXmlFileException e) { openOOXML(new FileInputStream(file)); } } public VBAMacroReader(POIFSFileSystem fs) {
/** * Read from an InputStream and process the documents we get * * @param stream the InputStream from which to read the data * * @exception IOException on errors reading, or on invalid data */ public void read(final InputStream stream) throws IOException { try (POIFSFileSystem poifs = new POIFSFileSystem(stream)) { read(poifs); } }
public static void main(String[] args) throws IOException { for (String file : args) { try (HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor( new POIFSFileSystem(new File(file)))) { System.out.println(ext.getText()); } } } }
/** * Read from a File and process the documents we get * * @param poifsFile the file from which to read the data * * @exception IOException on errors reading, or on invalid data */ public void read(final File poifsFile) throws IOException { try (POIFSFileSystem poifs = new POIFSFileSystem(poifsFile, true)) { read(poifs); } }
@Override public Excel03SaxReader read(InputStream excelStream, int sheetIndex) throws POIException { try { return read(new POIFSFileSystem(excelStream), sheetIndex); } catch (IOException e) { throw new POIException(e); } }
@Override public Excel03SaxReader read(File file, int sheetIndex) throws POIException { try { return read(new POIFSFileSystem(file), sheetIndex); } catch (IOException e) { throw new POIException(e); } }
@Override public Excel03SaxReader read(InputStream excelStream, int sheetIndex) throws POIException { try { return read(new POIFSFileSystem(excelStream), sheetIndex); } catch (IOException e) { throw new POIException(e); } }
@Override public Excel03SaxReader read(File file, int sheetIndex) throws POIException { try { return read(new POIFSFileSystem(file), sheetIndex); } catch (IOException e) { throw new POIException(e); } }
public XlsSaxAnalyser(AnalysisContext context) throws IOException { this.analysisContext = context; this.records = new ArrayList<String>(); if (analysisContext.getCurrentSheet() == null) { this.analyAllSheet = true; } context.setCurrentRowNum(0); this.fs = new POIFSFileSystem(analysisContext.getInputStream()); }
HSSFWorkbook myWorkBook = new HSSFWorkbook(new POIFSFileSystem(new FileInputStream("E:/Project/SpringHibernet/MultiplexTicketBookingNew/web/excelSheets/Country.xlsx"))); HSSFSheet mySheet = myWorkBook.getSheetAt(0); Iterator rowIter = mySheet.rowIterator(); System.out.println(mySheet.getRow(1).getCell(0));
public static void viewFileOld(final String filename, boolean withSizes) throws IOException { POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename)); displayDirectory(fs.getRoot(), "", withSizes); fs.close(); }
public static void viewFile(final String filename, boolean withSizes) throws IOException { POIFSFileSystem fs = new POIFSFileSystem(new File(filename)); displayDirectory(fs.getRoot(), "", withSizes); fs.close(); }
/** * Write out, with any properties changes, but nothing else */ public void write(OutputStream out) throws IOException { try (POIFSFileSystem fs = new POIFSFileSystem()) { write(fs); fs.writeFilesystem(out); } }
@Override public DirectoryEntry getDirectory() throws IOException { try (InputStream is = getObjectPart().getInputStream()) { return new POIFSFileSystem(is).getRoot(); } }
public VBAMacroReader(InputStream rstream) throws IOException { InputStream is = FileMagic.prepareToCheckMagic(rstream); FileMagic fm = FileMagic.valueOf(is); if (fm == FileMagic.OLE2) { fs = new POIFSFileSystem(is); } else { openOOXML(is); } }
public void run() throws IOException { try (POIFSFileSystem fs = new POIFSFileSystem(new File(file), true); InputStream din = BiffViewer.getPOIFSInputStream(fs)) { HSSFRequest req = new HSSFRequest(); req.addListenerForAllRecords(System.out::println); HSSFEventFactory factory = new HSSFEventFactory(); factory.processEvents(req, din); } }
protected EmbeddedData extract(DirectoryNode dn) throws IOException { assert(canExtract(dn)); ByteArrayOutputStream bos = new ByteArrayOutputStream(20000); try (POIFSFileSystem dest = new POIFSFileSystem()) { copyNodes(dn, dest.getRoot()); // start with a reasonable big size dest.writeFilesystem(bos); } return new EmbeddedData(dn.getName(), bos.toByteArray(), CONTENT_TYPE_BYTES); }
@Override public DataOut streamParse( final InputStream is, final DataOut dout) throws Exception { _dout = dout; _firstRow = true; try { _fs = new POIFSFileSystem(is); MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this); _formatListener = new FormatTrackingHSSFListener(listener); HSSFEventFactory factory = new HSSFEventFactory(); HSSFRequest request = new HSSFRequest(); request.addListenerForAllRecords(_formatListener); factory.processWorkbookEvents(request, _fs); } finally { try { is.close(); } catch (IOException e) { } } return dout; }
public static POITextExtractor createExtractor(InputStream inp) throws IOException, OpenXML4JException, XmlException { InputStream is = FileMagic.prepareToCheckMagic(inp); FileMagic fm = FileMagic.valueOf(is); switch (fm) { case OLE2: POIFSFileSystem fs = new POIFSFileSystem(is); boolean isEncrypted = fs.getRoot().hasEntry(Decryptor.DEFAULT_POIFS_ENTRY); return isEncrypted ? createEncryptedOOXMLExtractor(fs) : createExtractor(fs); case OOXML: return createExtractor(OPCPackage.open(is)); default: throw new IllegalArgumentException("Your InputStream was neither an OLE2 stream, nor an OOXML stream"); } }