public static Worksheet Read(Stream stream) { Record record = Record.Read(stream); Record last_record = record; last_record.Decode(); if (record is BOF && ((BOF)record).StreamType == StreamType.Worksheet) { Worksheet sheet = new Worksheet(); while (record.Type != RecordType.EOF) { if (record.Type == RecordType.CONTINUE) { last_record.ContinuedRecords.Add(record); } else { switch (record.Type) { case RecordType.STRING: if (last_record is FORMULA) { record.Decode(); (last_record as FORMULA).StringRecord = record as STRING; } break; case RecordType.MSODRAWING: if (sheet.Drawing == null) { sheet.Drawing = record as MSODRAWING; sheet.Records.Add(record); } else { sheet.Drawing.ContinuedRecords.Add(record); } break; default: sheet.Records.Add(record); break; } last_record = record; } record = Record.Read(stream); } return(sheet); } else { return(null); } }
private void ReadRecords(Stream stream) { 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); } } else { throw new Exception("Invalid Workbook."); } }