Example #1
0
        private static List <Record> ReadRecords(Stream stream, out MSODRAWINGGROUP drawingGroup)
        {
            List <Record> records = new List <Record>();

            drawingGroup = null;
            Record record = Record.Read(stream);

            record.Decode();
            Record last_record = record;

            if (record is BOF && ((BOF)record).StreamType == StreamType.WorkbookGlobals)
            {
                while (record.Type != RecordType.EOF)
                {
                    if (record.Type == RecordType.CONTINUE)
                    {
                        last_record.ContinuedRecords.Add(record);
                    }
                    else
                    {
                        switch (record.Type)
                        {
                        case RecordType.MSODRAWINGGROUP:
                            if (drawingGroup == null)
                            {
                                drawingGroup = record as MSODRAWINGGROUP;
                                records.Add(record);
                            }
                            else
                            {
                                drawingGroup.ContinuedRecords.Add(record);
                            }
                            break;

                        default:
                            records.Add(record);
                            break;
                        }
                        last_record = record;
                    }
                    record = Record.Read(stream);
                }
                records.Add(record);
            }
            else
            {
                throw new Exception("Invalid Workbook.");
            }
            return(records);
        }
Example #2
0
        private static List <Record> ReadRecords(Stream stream, out MSODRAWING drawingRecord)
        {
            List <Record> records = new List <Record>();

            drawingRecord = null;
            Record record              = Record.Read(stream);
            Record last_record         = record;
            Record last_formula_record = null;

            last_record.Decode();
            if (record is BOF && ((BOF)record).StreamType == StreamType.Worksheet)
            {
                while (record.Type != RecordType.EOF)
                {
                    if (record.Type == RecordType.CONTINUE)
                    {
                        last_record.ContinuedRecords.Add(record);
                    }
                    else
                    {
                        switch (record.Type)
                        {
                        case RecordType.STRING:
                            // jetcat_au: use last_formula_record instead of last_record
                            if (last_formula_record is FORMULA)
                            {
                                record.Decode();
                                (last_formula_record as FORMULA).StringRecord = record as STRING;
                            }
                            break;

                        case RecordType.MSODRAWING:
                            if (drawingRecord == null)
                            {
                                drawingRecord = record as MSODRAWING;
                                records.Add(record);
                            }
                            else
                            {
                                drawingRecord.ContinuedRecords.Add(record);
                            }
                            break;

                        default:
                            records.Add(record);
                            break;
                        }
                        // jetcat_au: see 4.8 Array Formulas and Shared Formulas
                        if (record.Type == RecordType.FORMULA)
                        {
                            last_formula_record = record;
                        }
                        else if (record.Type != RecordType.SHRFMLA && record.Type != RecordType.ARRAY)
                        {
                            last_formula_record = null;
                        }
                        last_record = record;
                    }
                    record = Record.Read(stream);
                }
                records.Add(record);
            }
            return(records);
        }