public WorkbookStream(string filePath) { using (var fs = new FileStream(filePath, FileMode.Open)) { StructuredStorageReader ssr = new StructuredStorageReader(fs); try { var wbStream = ssr.GetStream("Workbook"); byte[] wbBytes = new byte[wbStream.Length]; wbStream.Read(wbBytes, 0, wbBytes.Length, 0); _biffRecords = RecordHelper.ParseBiffStreamBytes(wbBytes); } catch (StreamNotFoundException) { var wbStream = ssr.GetStream("Book"); Console.WriteLine("WARNING: Main stream is in a Book record indicating legacy Excel 5 BIFF format. This may not parse correctly."); byte[] wbBytes = new byte[wbStream.Length]; wbStream.Read(wbBytes, 0, wbBytes.Length, 0); try { _biffRecords = RecordHelper.ParseBiffStreamBytes(wbBytes); } catch (Exception) { throw new NotImplementedException("Error parsing Book stream: Macrome currently doesn't support the Excel 5 BIFF format."); } } } }
public WorkbookStream(string filePath) { using (var fs = new FileStream(filePath, FileMode.Open)) { StructuredStorageReader ssr = new StructuredStorageReader(fs); var wbStream = ssr.GetStream("Workbook"); byte[] wbBytes = new byte[wbStream.Length]; wbStream.Read(wbBytes, 0, wbBytes.Length, 0); _biffRecords = RecordHelper.ParseBiffStreamBytes(wbBytes); } }
public WorkbookStream AddSheet(BoundSheet8 sheetHeader, byte[] sheetBytes) { WorkbookStream newStream = new WorkbookStream(Records); List <BoundSheet8> existingBoundSheets = newStream.GetAllRecordsByType <BoundSheet8>(); BoundSheet8 lastSheet8 = existingBoundSheets.Last(); newStream = newStream.InsertRecord(sheetHeader, lastSheet8); List <BiffRecord> sheetRecords = RecordHelper.ParseBiffStreamBytes(sheetBytes); newStream = newStream.InsertRecords(sheetRecords); newStream = newStream.FixBoundSheetOffsets(); return(newStream); }
public WorkbookStream(byte[] workbookBytes) { _biffRecords = RecordHelper.ParseBiffStreamBytes(workbookBytes); }