Examples of POIFSFileSystem


Examples of org.apache.poi.poifs.filesystem.POIFSFileSystem

     *  Method run starts up BiffViewer...
     */

    public void run() {
        try {
            POIFSFileSystem fs =
                    new POIFSFileSystem(new FileInputStream(filename));
            InputStream stream =
                    fs.createDocumentInputStream("Workbook");
            createRecords(stream, dump);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of org.apache.poi.poifs.filesystem.POIFSFileSystem

                BiffViewer viewer = new BiffViewer(args);
                if ((args.length > 1) && args[1].equals("on")) {
                    viewer.setDump(true);
                }
                if ((args.length > 1) && args[1].equals("bfd")) {
                    POIFSFileSystem fs =
                            new POIFSFileSystem(new FileInputStream(args[0]));
                    InputStream stream =
                            fs.createDocumentInputStream("Workbook");
                    int size = stream.available();
                    byte[] data = new byte[size];

                    stream.read(data);
                    HexDump.dump(data, 0, System.out, 0);
View Full Code Here

Examples of org.apache.poi.poifs.filesystem.POIFSFileSystem

   * @throws IOException if there is a problem while parsing the document.
   */
  public HSLFSlideShow(InputStream inputStream) throws IOException
  {
    //do Ole stuff
    this(new POIFSFileSystem(inputStream));
    istream = inputStream;
  }
View Full Code Here

Examples of org.apache.poi.poifs.filesystem.POIFSFileSystem

   @throws IOException If there is an unexpected IOException from the passed
   *            in OutputStream
   */
   public void write(OutputStream out) throws IOException {
  // Get a new Filesystem to write into
  POIFSFileSystem outFS = new POIFSFileSystem();

  // Write out the Property Streams
  writeProperties(outFS);


  // For position dependent records, hold where they were and now are
  // As we go along, update, and hand over, to any Position Dependent
  //  records we happen across
  Hashtable oldToNewPositions = new Hashtable();
 
  // First pass - figure out where all the position dependent
  //   records are going to end up, in the new scheme
  // (Annoyingly, some powerpoing files have PersistPtrHolders
  //  that reference slides after the PersistPtrHolder)
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  for(int i=0; i<_records.length; i++) {
    if(_records[i] instanceof PositionDependentRecord) {
      PositionDependentRecord pdr = (PositionDependentRecord)_records[i];
      int oldPos = pdr.getLastOnDiskOffset();
      int newPos = baos.size();
      pdr.setLastOnDiskOffset(newPos);
      oldToNewPositions.put(new Integer(oldPos),new Integer(newPos));
      //System.out.println(oldPos + " -> " + newPos);
    }
   
    // Dummy write out, so the position winds on properly
    _records[i].writeOut(baos);
  }

  // No go back through, actually writing ourselves out
  baos.reset();
  for(int i=0; i<_records.length; i++) {
    // For now, we're only handling PositionDependentRecord's that
    //  happen at the top level.
    // In future, we'll need the handle them everywhere, but that's
    //  a bit trickier
    if(_records[i] instanceof PositionDependentRecord) {
      // We've already figured out their new location, and
      //  told them that
      // Tell them of the positions of the other records though
      PositionDependentRecord pdr = (PositionDependentRecord)_records[i];
      pdr.updateOtherRecordReferences(oldToNewPositions);
    }

    // Whatever happens, write out that record tree
    _records[i].writeOut(baos);
  }
  // Update our cached copy of the bytes that make up the PPT stream
  _docstream = baos.toByteArray();

  // Write the PPT stream into the POIFS layer
  ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
  outFS.createDocument(bais,"PowerPoint Document");


  // Update and write out the Current User atom
  int oldLastUserEditAtomPos = (int)currentUser.getCurrentEditOffset();
  Integer newLastUserEditAtomPos = (Integer)oldToNewPositions.get(new Integer(oldLastUserEditAtomPos));
  if(newLastUserEditAtomPos == null) {
    throw new RuntimeException("Couldn't find the new location of the UserEditAtom that used to be at " + oldLastUserEditAtomPos);
  }
  currentUser.setCurrentEditOffset(newLastUserEditAtomPos.intValue());
  currentUser.writeToFS(outFS);

 
  // Write any pictures, into another stream
  if (_pictures != null) {
    ByteArrayOutputStream pict = new ByteArrayOutputStream();
    for (int i = 0; i < _pictures.length; i++ ) {
      _pictures[i].write(pict);
    }
    outFS.createDocument(
        new ByteArrayInputStream(pict.toByteArray()), "Pictures"
    );
  }

  // Send the POIFSFileSystem object out to the underlying stream
  outFS.writeFilesystem(out);
   }
View Full Code Here

Examples of org.apache.poi.poifs.filesystem.POIFSFileSystem

  /**
   * Creates an extractor from a given input stream
   * @param iStream
   */
  public QuickButCruddyTextExtractor(InputStream iStream) throws IOException {
    this(new POIFSFileSystem(iStream));
    is = iStream;
  }
View Full Code Here

Examples of org.apache.poi.poifs.filesystem.POIFSFileSystem

                    } catch (RepositoryException e) {
                        throw new IOException(e.getMessage());
                    }

                    try {
                        POIFSFileSystem fs = new POIFSFileSystem(in);
                        HSSFWorkbook workbook = new HSSFWorkbook(fs);

                        for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
                            HSSFSheet sheet = workbook.getSheetAt(i);
View Full Code Here

Examples of org.apache.poi.poifs.filesystem.POIFSFileSystem

  public final void openExcelFileForRead(final String excelFileName)
      throws ProTransException {
    try {
      File excelFile = getFile(excelFileName);
      POIFSFileSystem fileSystem = new POIFSFileSystem(
          new FileInputStream(excelFile));
      HSSFWorkbook workbook = new HSSFWorkbook(fileSystem);
      readSheet = workbook.getSheetAt(0);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
View Full Code Here

Examples of org.apache.poi.poifs.filesystem.POIFSFileSystem

     *  Method run starts up BiffViewer...
     */

    public void run() {
        try {
            POIFSFileSystem fs =
                    new POIFSFileSystem(new FileInputStream(filename));
            InputStream stream =
                    fs.createDocumentInputStream("Workbook");
            createRecords(stream, dump);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of org.apache.poi.poifs.filesystem.POIFSFileSystem

                BiffViewer viewer = new BiffViewer(args);
                if ((args.length > 1) && args[1].equals("on")) {
                    viewer.setDump(true);
                }
                if ((args.length > 1) && args[1].equals("bfd")) {
                    POIFSFileSystem fs =
                            new POIFSFileSystem(new FileInputStream(args[0]));
                    InputStream stream =
                            fs.createDocumentInputStream("Workbook");
                    int size = stream.available();
                    byte[] data = new byte[size];

                    stream.read(data);
                    HexDump.dump(data, 0, System.out, 0);
View Full Code Here

Examples of org.apache.poi.poifs.filesystem.POIFSFileSystem

    public void run()
        throws IOException
    {
        FileInputStream fin   = new FileInputStream(file);
        POIFSFileSystem poifs = new POIFSFileSystem(fin);
        InputStream     din   = poifs.createDocumentInputStream("Workbook");
        HSSFRequest     req   = new HSSFRequest();

        req.addListenerForAllRecords(new HSSFListener()
        {
            public void processRecord(Record rec)
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.