private void Load(CompoundFile doc) { Stream stream; try { // see if workbook works stream = doc.OpenStream("Workbook"); } catch (IOException) { // see if book works, if not then leak the exception stream = doc.OpenStream("Book"); } SstRecord sst = null; /* long sstPos = 0; */ // record position dictionary SortedList<long, Biff> records = new SortedList<long, Biff>(); _styles = new StyleCollection(this); _formats = new FormatCollection(this); _fonts = new FontCollection(this); _palette = new Palette(this); _hyperLinks = new HyperLinkCollection(this); while (stream.Length - stream.Position >= GenericBiff.MinimumSize) { // capture the current stream position long pos = stream.Position; // decode the record if possible Biff record = GetCorrectRecord(new GenericBiff(stream), stream, sst); // capture // shared string table if (record is SstRecord) { Debug.Assert(sst == null); sst = (SstRecord)record; /* sstPos = pos; */ } // formatting records else if (record is FormatRecord) { FormatRecord f = (FormatRecord)record; _formats.Add(f.Index, new Format(this, f)); } else if (record is FontRecord) _fonts.Add(new Font(this, (FontRecord)record)); else if (record is PaletteRecord) _palette.Initialize((PaletteRecord)record); else if (record is XfRecord) _styles.Add(new Style(this, (XfRecord)record)); else if (record is HyperLinkRecord) _hyperLinks.Add((HyperLinkRecord)record); Debug.Assert(!records.ContainsKey(pos)); // store the position and corresponding record records[pos] = record; } // generate the worksheets _sheets = new WorksheetCollection(); foreach (Biff record in records.Values) { if (record is BoundSheetRecord) _sheets.Add(new Worksheet(this, (BoundSheetRecord)record, records)); } }
private void Load(CompoundFile doc) { Stream stream; try { // see if workbook works stream = doc.OpenStream("Workbook"); } catch (IOException) { // see if book works, if not then leak the exception stream = doc.OpenStream("Book"); } SstRecord sst = null; long sstPos = 0; // record position dictionary SortedList <long, Biff> records = new SortedList <long, Biff>(); _styles = new StyleCollection(this); _formats = new FormatCollection(this); _fonts = new FontCollection(this); _palette = new Palette(this); _hyperLinks = new HyperLinkCollection(this); while (stream.Length - stream.Position >= GenericBiff.MinimumSize) { // capture the current stream position long pos = stream.Position; // decode the record if possible Biff record = GetCorrectRecord(new GenericBiff(stream), stream, sst); // capture // shared string table if (record is SstRecord) { Debug.Assert(sst == null); sst = (SstRecord)record; sstPos = pos; } // formatting records else if (record is FormatRecord) { FormatRecord f = (FormatRecord)record; _formats.Add(f.Index, new Format(this, f)); } else if (record is FontRecord) { _fonts.Add(new Font(this, (FontRecord)record)); } else if (record is PaletteRecord) { _palette.Initialize((PaletteRecord)record); } else if (record is XfRecord) { _styles.Add(new Style(this, (XfRecord)record)); } else if (record is HyperLinkRecord) { _hyperLinks.Add((HyperLinkRecord)record); } Debug.Assert(!records.ContainsKey(pos)); // store the position and corresponding record records[pos] = record; } // generate the worksheets _sheets = new WorksheetCollection(); foreach (Biff record in records.Values) { if (record is BoundSheetRecord) { _sheets.Add(new Worksheet(this, (BoundSheetRecord)record, records)); } } }