public CustomViewSettingsRecordAggregate(RecordStream rs)
 {
     _begin = rs.GetNext();
     if (_begin.Sid != UserSViewBegin.sid)
     {
         throw new InvalidOperationException("Bad begin record");
     }
     List<RecordBase> temp = new List<RecordBase>();
     while (rs.PeekNextSid() != UserSViewEnd.sid)
     {
         if (PageSettingsBlock.IsComponentRecord(rs.PeekNextSid()))
         {
             if (_psBlock != null)
             {
                 throw new InvalidOperationException(
                         "Found more than one PageSettingsBlock in custom view Settings sub-stream");
             }
             _psBlock = new PageSettingsBlock(rs);
             temp.Add(_psBlock);
             continue;
         }
         temp.Add(rs.GetNext());
     }
     _recs = temp;
     _end = rs.GetNext(); // no need to save EOF in field
     if (_end.Sid != UserSViewEnd.sid)
     {
         throw new InvalidOperationException("Bad custom view Settings end record");
     }
 }
 public bool ProcessRecord(Record rec)
 {
     wascalled[0] = true;
     Assert.IsTrue(
                (rec.Sid == BOFRecord.sid),
                "must be BOFRecord got SID=" + rec.Sid);
     return true;
 }
    /**
 * sends the record event to all registered listeners.
 * @param record the record to be thrown.
 * @return <c>false</c> to abort.  This aborts
 * out of the event loop should the listener return false
 */
    private bool ProcessRecord(Record record)
    {
        if (!IsSidIncluded(record.Sid))
        {
            return true;
        }
        return _listener.ProcessRecord(record);
    }
        /**
         * Process this record ourselves, and then
         *  pass it on to our child listener
         */
        public void ProcessRecord(Record record)
        {
            // Handle it ourselves
            ProcessRecordInternally(record);

            // Now pass on to our child
            childListener.ProcessRecord(record);
        }
 public void ProcessRecord(Record record)
 {
     if (record is AlRunsRecord)
     {
         chartTitleFormatRecords.Add(
                 record
         );
     }
 }
示例#6
0
        public RecordTreeNode(Record record)
        {
            if (record is ObjRecord)
            {
                ObjRecord or = (ObjRecord)record;
                IList subrecs=or.SubRecords;
                foreach (SubRecord sr in subrecs)
                {
                    this.Nodes.Add(new SubRecordTreeNode(sr));
                }
                this.ImageKey = "Folder";
                this.SelectedImageKey = "Folder";
            }
            else if (record is SSTRecord)
            {
                IEnumerator strings = ((SSTRecord)record).GetStrings();

                this.ImageKey = "Folder";
                this.SelectedImageKey = "Folder";

                while (strings.MoveNext())
                {
                    this.Nodes.Add(new UnicodeStringTreeNode((UnicodeString)strings.Current));
                }
            }
            else if (record is DrawingGroupRecord)
            {
                this.ImageKey = "Folder";
                this.SelectedImageKey = "Folder";

                DrawingGroupRecord dgr = (DrawingGroupRecord)record;

                for (int i = 0; i < dgr.EscherRecords.Count; i++)
                {
                    this.Nodes.Add(new EscherRecordTreeNode((NPOI.DDF.EscherRecord)dgr.EscherRecords[i]));
                }
                
            }
            else
            {
                this.ImageKey = "Binary";
            }
            if (record is UnknownRecord)
            {
                this.Text = UnknownRecord.GetBiffName(record.Sid) + "*";
            }
            else
            {
                this.Text = record.GetType().Name;
            }
            this.Record = record;
            
        }
 /**
  * Process the record ourselves, but do not
  *  pass it on to the child Listener.
  * @param record
  */
 public void ProcessRecordInternally(Record record)
 {
     if (record is FormatRecord)
     {
         FormatRecord fr = (FormatRecord)record;
         customFormatRecords[fr.IndexCode] = fr;
     }
     else if (record is ExtendedFormatRecord)
     {
         ExtendedFormatRecord xr = (ExtendedFormatRecord)record;
         xfRecords.Add(xr);
     }
 }
示例#8
0
        private void CreateFilterModeRecord(HSSFSheet sheet, int insertPos)
        {
            //look for the FilterModeRecord
            NPOI.HSSF.Record.Record record = sheet.Sheet.FindFirstRecordBySid(FilterModeRecord.sid);

            // this local variable hides the class one: FilterModeRecord filtermode;
            //if not found, add a new one
            if (record == null)
            {
                filtermode = new FilterModeRecord();
                sheet.Sheet.Records.Insert(insertPos, filtermode);
            }
        }
示例#9
0
 /// <summary>
 /// Adds the specified pos.
 /// </summary>
 /// <param name="pos">The pos.</param>
 /// <param name="r">The r.</param>
 public void Add(int pos, Record r)
 {
     records.Insert(pos, r);
     if (Protpos >= pos) Protpos=(protpos + 1);
     if (Bspos >= pos) Bspos=(bspos + 1);
     if (Tabpos >= pos) Tabpos=(tabpos + 1);
     if (Fontpos >= pos) Fontpos=(fontpos + 1);
     if (Xfpos >= pos) Xfpos=(xfpos + 1);
     if (Backuppos >= pos) Backuppos=(backuppos + 1);
     if (Namepos>= pos) Namepos=(namepos + 1);
     if (Supbookpos >= pos) Supbookpos=(supbookpos + 1);
     if ((Palettepos!= -1) && (Palettepos>= pos)) Palettepos=(palettepos + 1);
     if (ExternsheetPos >= pos) ExternsheetPos=ExternsheetPos + 1;
 }
示例#10
0
        /**
         * @return the number of {@link SharedFormulaRecord}s encoded for the specified sheet
         */
        private static int countSharedFormulas(ISheet sheet)
        {
            NPOI.HSSF.Record.Record[] records = RecordInspector.GetRecords(sheet, 0);
            int count = 0;

            for (int i = 0; i < records.Length; i++)
            {
                NPOI.HSSF.Record.Record rec = records[i];
                if (rec is SharedFormulaRecord)
                {
                    count++;
                }
            }
            return(count);
        }
示例#11
0
 public override void Dispose()
 {
     _rowBreaksRecord = null;
     _columnBreaksRecord = null;
     header = null;
     footer = null;
     _hCenter = null;
     _vCenter = null;
     _leftMargin = null;
     _rightMargin = null;
     _topMargin = null;
     _bottomMargin = null;
     _pls = null;
     printSetup = null;
     _bitmap = null;
 }
示例#12
0
        private void CreateAutoFilterInfoRecord(HSSFSheet sheet, int insertPos, Area3DPtg ptg)
        {
            //look for the AutoFilterInfo Record
            NPOI.HSSF.Record.Record record = sheet.Sheet.FindFirstRecordBySid(AutoFilterInfoRecord.sid);
            AutoFilterInfoRecord    info;

            if (record == null)
            {
                info = new AutoFilterInfoRecord();
                sheet.Sheet.Records.Insert(insertPos, info);
            }
            else
            {
                info = record as AutoFilterInfoRecord;
            }
            info.NumberOfFilterColumns = (short)(ptg.LastColumn - ptg.FirstColumn + 1);
        }
示例#13
0
        private static byte[] toByteArray(List <RecordBase> records)
        {
            MemoryStream out1 = new MemoryStream();

            foreach (RecordBase rb in records)
            {
                NPOI.HSSF.Record.Record r = (NPOI.HSSF.Record.Record)rb;
                try
                {
                    byte[] data = r.Serialize();
                    out1.Write(data, 0, data.Length);
                }
                catch (IOException e)
                {
                    throw new RuntimeException(e);
                }
            }
            return(out1.ToArray());
        }
示例#14
0
        public void TestDuplicatePLS_bug47415()
        {
            NPOI.HSSF.Record.Record   plsA   = ur(UnknownRecord.PLS_004D, "BA AD F0 0D");
            NPOI.HSSF.Record.Record   plsB   = ur(UnknownRecord.PLS_004D, "DE AD BE EF");
            NPOI.HSSF.Record.Record   contB1 = new ContinueRecord(HexRead.ReadFromString("FE ED"));
            NPOI.HSSF.Record.Record   contB2 = new ContinueRecord(HexRead.ReadFromString("FA CE"));
            NPOI.HSSF.Record.Record[] recs   =
            {
                new HeaderRecord("&LSales Figures"),
                new FooterRecord("&LInventory"),
                new HCenterRecord(),
                new VCenterRecord(),
                plsA,
                plsB,                               contB1, contB2, // make sure continuing PLS is still OK
            };
            RecordStream      rs = new RecordStream(Arrays.AsList(recs), 0);
            PageSettingsBlock psb;

            try
            {
                psb = new PageSettingsBlock(rs);
            }
            catch (RecordFormatException e)
            {
                if ("Duplicate PageSettingsBlock record (sid=0x4d)".Equals(e.Message))
                {
                    throw new AssertionException("Identified bug 47415");
                }
                throw e;
            }

            // serialize the PSB to see what records come out
            RecordInspector.RecordCollector rc = new RecordInspector.RecordCollector();
            psb.VisitContainedRecords(rc);
            NPOI.HSSF.Record.Record[] outRecs = rc.Records;

            // records were assembled in standard order, so this simple check is OK
            Assert.IsTrue(Arrays.Equals(recs, outRecs));
        }
示例#15
0
        //ERFListener
        public bool ProcessRecord(Record rec)
        {
            if (rec.Sid == BOFRecord.sid)
            {
                if (lastEOF != true)
                {
                    throw new Exception("Not yet handled embedded models");
                }
                else
                {
                    BOFRecord bof = (BOFRecord)rec;
                    switch (bof.Type)
                    {
                        case BOFRecord.TYPE_WORKBOOK:
                            currentmodel = new Workbook();
                            break;
                        case BOFRecord.TYPE_WORKSHEET:
                            currentmodel = Sheet.CreateSheet();
                            break;
                        default:
                            throw new Exception("Unsupported model type " + bof.GetType());
                    }

                }
            }

            if (rec.Sid == EOFRecord.sid)
            {
                lastEOF = true;
                ThrowEvent(currentmodel);
            }
            else
            {
                lastEOF = false;
            }


            return true;
        }
示例#16
0
 private static void VisitIfPresent(Record r, RecordVisitor rv)
 {
     if (r != null)
     {
         rv.VisitRecord(r);
     }
 }
示例#17
0
 public void VisitRecord(Record r)
 {
     if (!(r is DVRecord))
     {
         return;
     }
     DVRecord dvRecord = (DVRecord)r;
     CellRangeAddressList regions = dvRecord.CellRangeAddress.Copy();
     DVConstraint constraint = DVConstraint.CreateDVConstraint(dvRecord, book);
     HSSFDataValidation hssfDataValidation = new HSSFDataValidation(regions, constraint);
     hssfDataValidation.ErrorStyle = (dvRecord.ErrorStyle);
     hssfDataValidation.EmptyCellAllowed = (dvRecord.EmptyCellAllowed);
     hssfDataValidation.SuppressDropDownArrow = (dvRecord.SuppressDropdownArrow);
     hssfDataValidation.CreatePromptBox(dvRecord.PromptTitle, dvRecord.PromptText);
     hssfDataValidation.ShowPromptBox = (dvRecord.ShowPromptOnCellSelected);
     hssfDataValidation.CreateErrorBox(dvRecord.ErrorTitle, dvRecord.ErrorText);
     hssfDataValidation.ShowErrorBox = (dvRecord.ShowErrorOnInvalidValue);
     hssfValidations.Add(hssfDataValidation);
 }
示例#18
0
            public void VisitRecord(Record r)
            {
                if (r.Sid == UserSViewBegin.sid)
                {
                    String guid = HexDump.ToHex(((UserSViewBegin) r).Guid);
                    HeaderFooterRecord hf = _hfGuidMap[guid];

                    if (hf != null)
                    {
                        {
                            _cv.Append(_hf);
                            _sviewHeaderFooters.Remove(_hf);
                        }
                    }
                }
            }
示例#19
0
 private bool ReadARecord(RecordStream rs)
 {
     switch (rs.PeekNextSid())
     {
         case HorizontalPageBreakRecord.sid:
             CheckNotPresent(_rowBreaksRecord);
             _rowBreaksRecord = (PageBreakRecord)rs.GetNext();
             break;
         case VerticalPageBreakRecord.sid:
             CheckNotPresent(_columnBreaksRecord);
             _columnBreaksRecord = (PageBreakRecord)rs.GetNext();
             break;
         case HeaderRecord.sid:
             CheckNotPresent(header);
             header = (HeaderRecord)rs.GetNext();
             break;
         case FooterRecord.sid:
             CheckNotPresent(footer);
             footer = (FooterRecord)rs.GetNext();
             break;
         case HCenterRecord.sid:
             CheckNotPresent(_hCenter);
             _hCenter = (HCenterRecord)rs.GetNext();
             break;
         case VCenterRecord.sid:
             CheckNotPresent(_vCenter);
             _vCenter = (VCenterRecord)rs.GetNext();
             break;
         case LeftMarginRecord.sid:
             CheckNotPresent(_leftMargin);
             _leftMargin = (LeftMarginRecord)rs.GetNext();
             break;
         case RightMarginRecord.sid:
             CheckNotPresent(_rightMargin);
             _rightMargin = (RightMarginRecord)rs.GetNext();
             break;
         case TopMarginRecord.sid:
             CheckNotPresent(_topMargin);
             _topMargin = (TopMarginRecord)rs.GetNext();
             break;
         case BottomMarginRecord.sid:
             CheckNotPresent(_bottomMargin);
             _bottomMargin = (BottomMarginRecord)rs.GetNext();
             break;
         case UnknownRecord.PLS_004D: // PLS
             _plsRecords.Add(new PLSAggregate(rs));
             break;
         case PrintSetupRecord.sid:
             CheckNotPresent(printSetup);
             printSetup = (PrintSetupRecord)rs.GetNext();
             break;
         case UnknownRecord.BITMAP_00E9: // BITMAP
             CheckNotPresent(_bitmap);
             _bitmap = rs.GetNext();
             break;
         case PrintSizeRecord.sid:
             CheckNotPresent(_printSize);
             _printSize = rs.GetNext();
             break;
         case HeaderFooterRecord.sid:
             HeaderFooterRecord hf = (HeaderFooterRecord)rs.GetNext();
             if (hf.IsCurrentSheet)
                 _headerFooter = hf;
             else
                 _sviewHeaderFooters.Add(hf);
             break;
         default:
             // all other record types are not part of the PageSettingsBlock
             return false;
     }
     return true;
 }
示例#20
0
 public void VisitRecord(Record r)
 {
     if (r is LabelSSTRecord)
     {
         _count++;
     }
 }
示例#21
0
 /// <summary>
 /// Process the record ourselves, but do not
 /// pass it on to the child Listener.
 /// </summary>
 /// <param name="record">The record.</param>
 public void ProcessRecordInternally(Record record)
 {
     if (record is BoundSheetRecord)
     {
         boundSheetRecords.Add(record);
     }
     else if (record is ExternSheetRecord)
     {
         externSheetRecords.Add(record);
     }
     else if (record is SSTRecord)
     {
         sstRecord = (SSTRecord)record;
     }
 }
示例#22
0
 private bool ReadARecord(RecordStream rs)
 {
     switch (rs.PeekNextSid())
     {
         case HorizontalPageBreakRecord.sid:
             _rowBreaksRecord = (PageBreakRecord)rs.GetNext();
             _rowRecords.Add(_rowBreaksRecord);
             break;
         case VerticalPageBreakRecord.sid:
             _columnBreaksRecord = (PageBreakRecord)rs.GetNext();
             _rowRecords.Add(_columnBreaksRecord);
             break;
         case HeaderRecord.sid:
             header = (HeaderRecord)rs.GetNext();
             _rowRecords.Add(header);
             break;
         case FooterRecord.sid:
             footer = (FooterRecord)rs.GetNext();
             _rowRecords.Add(footer);
             break;
         case HCenterRecord.sid:
             _hCenter = (HCenterRecord)rs.GetNext();
             _rowRecords.Add(_hCenter);
             break;
         case VCenterRecord.sid:
             _vCenter = (VCenterRecord)rs.GetNext();
             _rowRecords.Add(_vCenter);
             break;
         case LeftMarginRecord.sid:
             _leftMargin = (LeftMarginRecord)rs.GetNext();
             _rowRecords.Add(_leftMargin);
             break;
         case RightMarginRecord.sid:
             _rightMargin = (RightMarginRecord)rs.GetNext();
             _rowRecords.Add(_rightMargin);
             break;
         case TopMarginRecord.sid:
             _topMargin = (TopMarginRecord)rs.GetNext();
             _rowRecords.Add(_topMargin);
             break;
         case BottomMarginRecord.sid:
             _bottomMargin = (BottomMarginRecord)rs.GetNext();
             _rowRecords.Add(_bottomMargin);
             break;
         case 0x004D: // PLS
             _pls = rs.GetNext();
             _rowRecords.Add(_pls);
             break;
         case PrintSetupRecord.sid:
             printSetup = (PrintSetupRecord)rs.GetNext();
             _rowRecords.Add(printSetup);
             break;
         case 0x00E9: // BITMAP
             _bitmap = rs.GetNext();
             _rowRecords.Add(_bitmap);
             break;
         default:
             // all other record types are not part of the PageSettingsBlock
             return false;
     }
     return true;
 }
            public void ProcessRecord(Record record)
            {
                _records.Add(record);

                if (record is MissingRowDummyRecord)
                {
                    MissingRowDummyRecord mr = (MissingRowDummyRecord)record;
                    log("Got dummy row " + mr.RowNumber);
                }
                if (record is MissingCellDummyRecord)
                {
                    MissingCellDummyRecord mc = (MissingCellDummyRecord)record;
                    log("Got dummy cell " + mc.Row + " " + mc.Column);
                }
                if (record is LastCellOfRowDummyRecord)
                {
                    LastCellOfRowDummyRecord lc = (LastCellOfRowDummyRecord)record;
                    log("Got end-of row, row was " + lc.Row + ", last column was " + lc.LastColumnNumber);
                }

                if (record is BOFRecord)
                {
                    BOFRecord r = (BOFRecord)record;
                    if (r.Type == BOFRecord.TYPE_WORKSHEET)
                    {
                        log("On new sheet");
                    }
                }
                if (record is RowRecord)
                {
                    RowRecord rr = (RowRecord)record;
                    log("Starting row #" + rr.RowNumber);
                }
            }
示例#24
0
 public AbortableCountingListener(int abortAfter)
 {
     abortAfterIndex = abortAfter;
     countSeen = 0;
     lastRecordSeen = null;
 }
示例#25
0
            public override short AbortableProcessRecord(Record record)
            {
                countSeen++;
                lastRecordSeen = record;

                if (countSeen == abortAfterIndex)
                {
                    return 1234;
                }
                return 0;
            }
示例#26
0
 public void VisitRecord(NPOI.HSSF.Record.Record r)
 {
     container.Add((RecordBase)r);
 }
示例#27
0
文件: TestSheet.cs 项目: 89sos98/npoi
 public void VisitRecord(Record r) {
     if (r is MergeCellsRecord) {
         _count++;
     }
 }
示例#28
0
文件: TestSheet.cs 项目: 89sos98/npoi
            public void VisitRecord(Record r)
            {

                int estimatedSize = r.RecordSize;
                byte[] buf = new byte[estimatedSize];
                int serializedSize = r.Serialize(0, buf);
                if (estimatedSize != serializedSize)
                {
                    throw new AssertionException("serialized size mismatch for record ("
                            + r.GetType().Name + ")");
                }
                _totalSize += estimatedSize;
            }
示例#29
0
 private void CheckNotPresent(Record rec)
 {
     if (rec != null)
     {
         throw new RecordFormatException("Duplicate WorksheetProtectionBlock record (sid=0x"
                 + StringUtil.ToHexString(rec.Sid) + ")");
     }
 }
示例#30
0
文件: InternalChart.cs 项目: WPG/npoi
 private void CheckNotPresent(Record.Record rec)
 {
     if (rec != null)
     {
         throw new RecordFormatException("Duplicate PageSettingsBlock record (sid=0x"
                 + StringUtil.ToHexString(rec.Sid) + ")");
     }
 }
        /**
         * @return the next available record, or <code>null</code> if
         * this pass didn't return a record that's
         * suitable for returning (eg was a continue record).
         */
        private Record ReadNextRecord()
        {
            Record record = RecordFactory.CreateSingleRecord(_recStream);

            _lastRecordWasEOFLevelZero = false;

            if (record is BOFRecord)
            {
                _bofDepth++;
                return(record);
            }

            if (record is EOFRecord)
            {
                _bofDepth--;
                if (_bofDepth < 1)
                {
                    _lastRecordWasEOFLevelZero = true;
                }

                return(record);
            }

            if (record is DBCellRecord)
            {
                // Not needed by POI.  Regenerated from scratch by POI when spreadsheet is written
                return(null);
            }

            if (record is RKRecord)
            {
                return(RecordFactory.ConvertToNumberRecord((RKRecord)record));
            }

            if (record is MulRKRecord)
            {
                Record[] records = RecordFactory.ConvertRKRecords((MulRKRecord)record);

                _unreadRecordBuffer = records;
                _unreadRecordIndex  = 1;
                return(records[0]);
            }

            if (record.Sid == DrawingGroupRecord.sid &&
                _lastRecord is DrawingGroupRecord)
            {
                DrawingGroupRecord lastDGRecord = (DrawingGroupRecord)_lastRecord;
                lastDGRecord.Join((AbstractEscherHolderRecord)record);
                return(null);
            }
            if (record.Sid == ContinueRecord.sid)
            {
                ContinueRecord contRec = (ContinueRecord)record;

                if (_lastRecord is ObjRecord || _lastRecord is TextObjectRecord)
                {
                    // Drawing records have a very strange continue behaviour.
                    //There can actually be OBJ records mixed between the continues.
                    _lastDrawingRecord.ProcessContinueRecord(contRec.Data);
                    //we must remember the position of the continue record.
                    //in the serialization procedure the original structure of records must be preserved
                    if (_shouldIncludeContinueRecords)
                    {
                        return(record);
                    }
                    return(null);
                }
                if (_lastRecord is DrawingGroupRecord)
                {
                    ((DrawingGroupRecord)_lastRecord).ProcessContinueRecord(contRec.Data);
                    return(null);
                }
                if (_lastRecord is DrawingRecord)
                {
                    ((DrawingRecord)_lastRecord).ProcessContinueRecord(contRec.Data);
                    return(null);
                }
                if (_lastRecord is UnknownRecord)
                {
                    //Gracefully handle records that we don't know about,
                    //that happen to be continued
                    return(record);
                }
                if (_lastRecord is EOFRecord)
                {
                    // This is really odd, but excel still sometimes
                    //  outPuts a file like this all the same
                    return(record);
                }
                throw new RecordFormatException("Unhandled Continue Record");
            }
            _lastRecord = record;
            if (record is DrawingRecord)
            {
                _lastDrawingRecord = (DrawingRecord)record;
            }
            return(record);
        }
示例#32
0
 public void VisitRecord(Record r)
 {
     _list.Add(r);
 }
示例#33
0
 public void VisitRecord(Record r)
 {
     if (r.Sid == UserSViewBegin.sid)
     {
         byte[] guid1 = ((UserSViewBegin)r).Guid;
         byte[] guid2 = _hf.Guid;
         if (Arrays.Equals(guid1, guid2))
         {
             _cv.Append(_hf);
             _sviewHeaderFooters.Remove(_hf);
         }
     }
 }
示例#34
0
文件: TestSheet.cs 项目: 89sos98/npoi
 public void VisitRecord(Record r)
 {
     if (r is IndexRecord)
     {
         if (_indexRecord != null)
         {
             throw new Exception("too many index records");
         }
         _indexRecord = (IndexRecord)r;
     }
 }
示例#35
0
        /**
  * Handles UnknownRecords which appear within the row/cell records
  */
        private void AddUnknownRecord(Record rec)
        {
            // ony a few distinct record IDs are encountered by the existing POI test cases:
            // 0x1065 // many
            // 0x01C2 // several
            // 0x0034 // few
            // No documentation could be found for these

            // keep the unknown records for re-serialization
            _unknownRecords.Add(rec);
        }
            /// <summary>
            /// Process an HSSF Record. Called when a record occurs in an HSSF file.
            /// </summary>
            /// <param name="record"></param>
            public void ProcessRecord(Record record)
            {
                String thisText = null;
                int thisRow = -1;

                switch (record.Sid)
                {
                    case BoundSheetRecord.sid:
                        BoundSheetRecord sr = (BoundSheetRecord)record;
                        sheetNames.Add(sr.Sheetname);
                        break;
                    case BOFRecord.sid:
                        BOFRecord bof = (BOFRecord)record;
                        if (bof.Type == BOFRecord.TYPE_WORKSHEET)
                        {
                            sheetNum++;
                            rowNum = -1;

                            if (includeSheetNames)
                            {
                                if (text.Length > 0) text.Append("\n");
                                text.Append(sheetNames[sheetNum]);
                            }
                        }
                        break;
                    case SSTRecord.sid:
                        sstRecord = (SSTRecord)record;
                        break;

                    case FormulaRecord.sid:
                        FormulaRecord frec = (FormulaRecord)record;
                        thisRow = frec.Row;

                        if (formulasNotResults)
                        {
                            thisText = HSSFFormulaParser.ToFormulaString((HSSFWorkbook)null, frec.ParsedExpression);
                        }
                        else
                        {
                            if (frec.HasCachedResultString)
                            {
                                // Formula result is a string
                                // This is stored in the next record
                                outputNextStringValue = true;
                                nextRow = frec.Row;
                            }
                            else
                            {
                                thisText = FormatNumberDateCell(frec, frec.Value);
                            }
                        }
                        break;
                    case StringRecord.sid:
                        if (outputNextStringValue)
                        {
                            // String for formula
                            StringRecord srec = (StringRecord)record;
                            thisText = srec.String;
                            thisRow = nextRow;
                            outputNextStringValue = false;
                        }
                        break;
                    case LabelRecord.sid:
                        LabelRecord lrec = (LabelRecord)record;
                        thisRow = lrec.Row;
                        thisText = lrec.Value;
                        break;
                    case LabelSSTRecord.sid:
                        LabelSSTRecord lsrec = (LabelSSTRecord)record;
                        thisRow = lsrec.Row;
                        if (sstRecord == null)
                        {
                            throw new Exception("No SST record found");
                        }
                        thisText = sstRecord.GetString(lsrec.SSTIndex).ToString();
                        break;
                    case NoteRecord.sid:
                        NoteRecord nrec = (NoteRecord)record;
                        thisRow = nrec.Row;
                        // TODO: Find object to match nrec.GetShapeId()
                        break;
                    case NumberRecord.sid:
                        NumberRecord numrec = (NumberRecord)record;
                        thisRow = numrec.Row;
                        thisText = FormatNumberDateCell(numrec, numrec.Value);
                        break;
                    default:
                        break;
                }

                if (thisText != null)
                {
                    if (thisRow != rowNum)
                    {
                        rowNum = thisRow;
                        if (text.Length > 0)
                            text.Append("\n");
                    }
                    else
                    {
                        text.Append("\t");
                    }
                    text.Append(thisText);
                }
            }
示例#37
0
 public void ProcessRecord(Record record)
 {
     records.Add(record);
 }