/** * Opens for decryption */ public EncryptionInfo(POIFSFileSystem fs) throws IOException { this(fs.getRoot()); }
/** * Constructs from the default POIFS * * @param fs the filesystem the document is read from */ protected POIDocument(POIFSFileSystem fs) { this(fs.getRoot()); }
public ExcelExtractor(POIFSFileSystem fs) throws IOException { this(fs.getRoot()); } public ExcelExtractor(DirectoryNode dir) throws IOException {
/** * Copies all nodes from one POIFS to the other * * @param source * is the source POIFS to copy from * @param target * is the target POIFS to copy to */ public static void copyNodes(POIFSFileSystem source, POIFSFileSystem target ) throws IOException { copyNodes( source.getRoot(), target.getRoot() ); }
/** * Processes a file into essentially record events. * * @param req an Instance of HSSFRequest which has your registered listeners * @param fs a POIFS filesystem containing your workbook * * @throws IOException if the workbook contained errors */ public void processWorkbookEvents(HSSFRequest req, POIFSFileSystem fs) throws IOException { processWorkbookEvents(req, fs.getRoot()); }
/** * Creates an instance of this class from an embedded OLE Object. The OLE Object is expected * to include a stream "{01}Ole10Native" which contains the actual * data relevant for this class. * * @param poifs POI Filesystem object * @return Returns an instance of this class * @throws IOException on IO error * @throws Ole10NativeException on invalid or unexcepted data format */ public static Ole10Native createFromEmbeddedOleObject(POIFSFileSystem poifs) throws IOException, Ole10NativeException { return createFromEmbeddedOleObject(poifs.getRoot()); }
/** * Add the \1OLE marker entry, which is not the Ole10Native entry. * Beside this "\u0001Ole" record there were several other records, e.g. CompObj, * OlePresXXX, but it seems, that they aren't necessary */ public static void createOleMarkerEntry(final POIFSFileSystem poifs) throws IOException { createOleMarkerEntry(poifs.getRoot()); }
/** * Give viewers a hint as to whether to call getViewableArray or * getViewableIterator * * @return true if a viewer should call getViewableArray, false if * a viewer should call getViewableIterator */ public boolean preferArray() { return getRoot().preferArray(); }
public EventBasedExcelExtractor(POIFSFileSystem fs) { this(fs.getRoot()); super.setFilesystem(fs); }
public static <T extends POITextExtractor> T createExtractor(POIFSFileSystem fs) throws IOException, OpenXML4JException, XmlException { return createExtractor(fs.getRoot()); }
public OutputStream getDataStream(POIFSFileSystem fs) throws IOException, GeneralSecurityException { return getDataStream(fs.getRoot()); }
/** * open a document in the root entry's list of entries * * @param documentName the name of the document to be opened * * @return a newly opened DocumentInputStream * * @exception IOException if the document does not exist or the * name is that of a DirectoryEntry */ public DocumentInputStream createDocumentInputStream( final String documentName) throws IOException { return getRoot().createDocumentInputStream(documentName); }
/** * Get an Iterator of objects, some of which may implement * POIFSViewable * * @return an Iterator; may not be null, but may have an empty * back end store */ public Iterator<Object> getViewableIterator() { if (!preferArray()) { return getRoot().getViewableIterator(); } return Collections.emptyList().iterator(); }
public static void viewFileOld(final String filename, boolean withSizes) throws IOException { POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename)); displayDirectory(fs.getRoot(), "", withSizes); fs.close(); }
/** * Get an array of objects, some of which may implement * POIFSViewable * * @return an array of Object; may not be null, but may be empty */ public Object [] getViewableArray() { if (preferArray()) { return getRoot().getViewableArray(); } return new Object[ 0 ]; }
static InputStream getPOIFSInputStream(POIFSFileSystem fs) throws IOException { String workbookName = HSSFWorkbook.getWorkbookDirEntryName(fs.getRoot()); return fs.createDocumentInputStream(workbookName); }
public static void viewFile(final String filename, boolean withSizes) throws IOException { POIFSFileSystem fs = new POIFSFileSystem(new File(filename)); displayDirectory(fs.getRoot(), "", withSizes); fs.close(); }
@Override public DirectoryEntry getDirectory() throws IOException { try (InputStream is = getObjectPart().getInputStream()) { return new POIFSFileSystem(is).getRoot(); } }
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); }
private void write(POIFSFileSystem fs) throws IOException { // For tracking what we've written out, so far List<String> excepts = new ArrayList<>(2); // Write out our HPFS properties, with any changes writeProperties(fs, excepts); // Copy over everything else unchanged FilteringDirectoryNode src = new FilteringDirectoryNode(getDirectory(), excepts); FilteringDirectoryNode dest = new FilteringDirectoryNode(fs.getRoot(), excepts); EntryUtils.copyNodes(src, dest); // Caller will save the resultant POIFSFileSystem to the stream/file } }