Package org.apache.poi.poifs.filesystem

Examples of org.apache.poi.poifs.filesystem.POIFSFileSystem.createDocument()


            final ByteArrayOutputStream psStream =
                new ByteArrayOutputStream();
            psOut.write(psStream);
            psStream.close();
            final byte[] streamData = psStream.toByteArray();
            poiFs.createDocument(new ByteArrayInputStream(streamData),
                                 psf1[i].getName());
            poiFs.writeFilesystem(out);
        }
        out.close();
View Full Code Here


        s.setDictionary(m);
        s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[0]);
        int codepage = CodePageUtil.CP_UNICODE;
        s.setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2,
                      Integer.valueOf(codepage));
        poiFs.createDocument(ps1.toInputStream(), "Test");
        poiFs.writeFilesystem(out);
        out.close();

        /* Read back: */
        final POIFile[] psf = Util.readPropertySets(copy);
View Full Code Here

            s.setDictionary(m);
            s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[0]);
            int codepage = 12345;
            s.setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2,
                          Integer.valueOf(codepage));
            poiFs.createDocument(ps1.toInputStream(), "Test");
            poiFs.writeFilesystem(out);
            out.close();
            fail("This testcase did not detect the invalid codepage value.");
        }
        catch (IllegalPropertySetDataException ex)
View Full Code Here

        //(a piece of code that used to work up to POI 3.0.2)
        SummaryInformation summary1 = (SummaryInformation)PropertySetFactory.create(fs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME));
        summary1.setTitle(title);
        //write the modified property back to POIFS
        fs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME).delete();
        fs.createDocument(summary1.toInputStream(), SummaryInformation.DEFAULT_STREAM_NAME);

        //save the workbook and read the property
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        wb.write(out);
        out.close();
View Full Code Here

        //set POIFS properties before constructing HSSFWorkbook
        SummaryInformation summary1 = (SummaryInformation)PropertySetFactory.create(fs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME));
        summary1.setTitle(title);

        fs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME).delete();
        fs.createDocument(summary1.toInputStream(), SummaryInformation.DEFAULT_STREAM_NAME);

        HSSFWorkbook wb = new HSSFWorkbook(fs);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        wb.write(out);
View Full Code Here

  public void testEmptyDocumentBug11744() throws Exception {
        byte[] testData = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

        POIFSFileSystem fs = new POIFSFileSystem();
        fs.createDocument(new ByteArrayInputStream(new byte[0]), "Empty");
        fs.createDocument(new ByteArrayInputStream(testData), "NotEmpty");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        fs.writeFilesystem(out);
        out.toByteArray();
View Full Code Here

  public void testEmptyDocumentBug11744() throws Exception {
        byte[] testData = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

        POIFSFileSystem fs = new POIFSFileSystem();
        fs.createDocument(new ByteArrayInputStream(new byte[0]), "Empty");
        fs.createDocument(new ByteArrayInputStream(testData), "NotEmpty");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        fs.writeFilesystem(out);
        out.toByteArray();

        // This line caused the error.
View Full Code Here

        {
            final ByteArrayOutputStream psStream = new ByteArrayOutputStream();
            ps.write(psStream);
            psStream.close();
            final byte[] streamData = psStream.toByteArray();
            poiFs.createDocument(new ByteArrayInputStream(streamData),
                                 SummaryInformation.DEFAULT_STREAM_NAME);
            poiFs.writeFilesystem(out);
            out.close();
            Assert.fail("Should have thrown a NoFormatIDException.");
        }
View Full Code Here

        final ByteArrayOutputStream psStream = new ByteArrayOutputStream();
        ps.write(psStream);
        psStream.close();
        final byte[] streamData = psStream.toByteArray();
        poiFs.createDocument(new ByteArrayInputStream(streamData),
                             SummaryInformation.DEFAULT_STREAM_NAME);
        poiFs.writeFilesystem(out);
        out.close();

        /* Read the POIFS: */
 
View Full Code Here

        p.setType(Variant.VT_LPWSTR);
        p.setValue(AUTHOR);
        si.setProperty(p);
        si.setProperty(PropertyIDMap.PID_TITLE, Variant.VT_LPSTR, TITLE);
   
        poiFs.createDocument(ps.toInputStream(),
                             SummaryInformation.DEFAULT_STREAM_NAME);
        poiFs.writeFilesystem(out);
        out.close();
   
        /* Read the POIFS: */
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.