Package org.apache.poi.hssf.record

Examples of org.apache.poi.hssf.record.Record


    private static int determineType(CellValueRecordInterface cval) {
        if (cval instanceof FormulaRecordAggregate) {
            return HSSFCell.CELL_TYPE_FORMULA;
        }
        // all others are plain BIFF records
        Record record = ( Record ) cval;
        switch (record.getSid()) {

            case NumberRecord.sid :   return HSSFCell.CELL_TYPE_NUMERIC;
            case BlankRecord.sid :    return HSSFCell.CELL_TYPE_BLANK;
            case LabelSSTRecord.sid : return HSSFCell.CELL_TYPE_STRING;
            case BoolErrRecord.sid :
View Full Code Here


    short sid = 0;
    process:
    {
                 
      Record rec       = null;

      while (in.hasNextRecord())
      {
                          in.nextRecord();
View Full Code Here

     *            InputStream
     */
    public void processRecords(InputStream in)
        throws RecordFormatException
    {
        Record    last_record = null;

        RecordInputStream recStream = new RecordInputStream(in);

        while (recStream.hasNextRecord()) {
          recStream.nextRecord();
          Record[] recs = createRecord(recStream);   // handle MulRK records
                    if (recs.length > 1)
                    {
                        for (int k = 0; k < recs.length; k++)
                        {
                            if ( last_record != null ) {
                                if (throwRecordEvent(last_record) == false && abortable == true) {
                                 last_record = null;
                                 break;  
                                }
                            }
                            last_record =
                                recs[ k ];                // do to keep the algorythm homogenous...you can't
                        }                                 // actually continue a number record anyhow.
                    }
                    else
                    {
                        Record record = recs[ 0 ];

                        if (record != null)
                        {
                                if (last_record != null) {
                                    if (throwRecordEvent(last_record) == false && abortable == true) {
View Full Code Here

     * create a record, if there are MUL records than multiple records
     * are returned digested into the non-mul form.
     */
    public static Record [] createRecord(RecordInputStream in)
    {
        Record   retval     = null;
        Record[] realretval = null;

        try
        {
            Constructor constructor =
View Full Code Here

    temp.toArray(_externalBookBlocks);
    temp.clear();
   
    if (_externalBookBlocks.length > 0) {
      // If any ExternalBookBlock present, there is always 1 of ExternSheetRecord
      Record next = rs.getNext();
      _externSheetRecord = (ExternSheetRecord) next;
    } else {
      _externSheetRecord = null;
    }
   
View Full Code Here

   * copied from Workbook
   */
  private int findFirstRecordLocBySid(short sid) {
    int index = 0;
    for (Iterator iterator = _workbookRecordList.iterator(); iterator.hasNext(); ) {
      Record record = ( Record ) iterator.next();

      if (record.getSid() == sid) {
        return index;
      }
      index ++;
    }
    return -1;
View Full Code Here

    process:
    try
    {
      byte[] sidbytes  = new byte[ 2 ];
      int    bytesread = in.read(sidbytes);
      Record rec       = null;

      while (bytesread > 0)
      {

        sid = LittleEndian.getShort(sidbytes);
               
                //
                // for some reasons we have to make the workbook to be at least 4096 bytes
                // but if we have such workbook we fill the end of it with zeros (many zeros)
                //
                // it is not good:
                // if the length( all zero records ) % 4 = 1
                // e.g.: any zero record would be readed as  4 bytes at once ( 2 - id and 2 - size ).
                // And the last 1 byte will be readed WRONG ( the id must be 2 bytes )
                //
                // So we should better to check if the sid is zero and not to read more data
                // The zero sid shows us that rest of the stream data is a fake to make workbook
                // certain size
                //
                if ( sid == 0 )
                    break;


        if ((rec != null) && (sid != ContinueRecord.sid))
        {
          userCode = req.processRecord(rec);
          if (userCode != 0) break process;
        }
        if (sid != ContinueRecord.sid)
        {
          short  size = LittleEndian.readShort(in);
          byte[] data = new byte[ size ];

          if (data.length > 0)
          {
            in.read(data);
          }
                                        //System.out.println("creating "+sid);
          Record[] recs = RecordFactory.createRecord(sid, size,
                                 data);

          if (recs.length > 1)
          {                                // we know that the multiple
            for (int k = 0; k < (recs.length - 1); k++)
            {                            // record situations do not
              userCode = req.processRecord(
                recs[ k ]);          // contain continue records
              if (userCode != 0) break process;
            }
          }
          rec = recs[ recs.length - 1 ];   // regardless we'll process

          // the last record as though
          // it might be continued
          // if there is only one
          // records, it will go here too.
        }
        else
        {                                    // we do have a continue record
          short  size = LittleEndian.readShort(in);
          byte[] data = new byte[ size ];

          if (data.length > 0)
          {
            in.read(data);
          }
          rec.processContinueRecord(data);
        }
        bytesread = in.read(sidbytes);       // read next record sid
      }
      if (rec != null)
      {
View Full Code Here

    /**
     * used internally -- given a cell value record, figure out its type
     */
    private int determineType(CellValueRecordInterface cval)
    {
        Record record = ( Record ) cval;
        int    sid    = record.getSid();
        int    retval = 0;

        switch (sid)
        {

View Full Code Here

     *            InputStream
     */
    public void processRecords(InputStream in)
        throws RecordFormatException
    {
        Record    last_record = null;

        try
        {
            short rectype = 0;

            do
            {
                rectype = LittleEndian.readShort(in);
                if (rectype != 0)
                {
                    short  recsize = LittleEndian.readShort(in);
                    byte[] data    = new byte[ ( int ) recsize ];

                    in.read(data);
                    Record[] recs = createRecord(rectype, recsize,
                                                 data);   // handle MulRK records

                    if (recs.length > 1)
                    {
                        for (int k = 0; k < recs.length; k++)
                        {
                            if ( last_record != null ) {
                                if (throwRecordEvent(last_record) == false && abortable == true) {
                                 last_record = null;
                                 break;  
                                }
                            }
                         //   records.add(
                         //       recs[ k ]);               // these will be number records
                            last_record =
                                recs[ k ];                // do to keep the algorythm homogenous...you can't
                        }                                 // actually continue a number record anyhow.
                    }
                    else
                    {
                        Record record = recs[ 0 ];

                        if (record != null)
                        {
                            if (rectype == ContinueRecord.sid &&
                                ! (last_record instanceof ContinueRecord) && // include continuation records after
View Full Code Here

     * are returned digested into the non-mul form.
     */
    public static Record [] createRecord(short rectype, short size,
                                         byte [] data)
    {
        Record   retval     = null;
        Record[] realretval = null;

        try
        {
            Constructor constructor =
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.Record

Copyright © 2018 www.massapicom. 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.