public void Save(string file) { CompoundDocument doc = CompoundDocument.Create(file); MemoryStream stream = new MemoryStream(); WorkbookEncoder.Encode(this, stream); doc.WriteStreamData(new string[] { "Workbook" }, stream.ToArray()); doc.Save(); doc.Close(); }
/// <summary> /// Save workbook to stream. /// </summary> /// <param name="stream"></param> public void Save(Stream stream) { CompoundDocument doc = CompoundDocument.Create(stream); using (MemoryStream memStream = new MemoryStream()) { WorkbookEncoder.Encode(this, memStream); doc.WriteStreamData(new string[] { "Workbook" }, memStream.ToArray()); doc.Save(); } }
private void _btSave_Click(object sender, EventArgs e) { if (doc == null) { return; } string file = FileSelector.BrowseFileForSave(FileType.All); if (file == null) { return; } using (CompoundDocument newDoc = CompoundDocument.Create(file)) { foreach (string streamName in doc.RootStorage.Members.Keys) { newDoc.WriteStreamData(new string[] { streamName }, doc.GetStreamData(streamName)); } byte[] bookdata = doc.GetStreamData("Workbook"); if (bookdata != null) { if (workbook == null) { workbook = WorkbookDecoder.Decode(new MemoryStream(bookdata)); } MemoryStream stream = new MemoryStream(); //WorkbookEncoder.Encode(workbook, stream); BinaryWriter writer = new BinaryWriter(stream); foreach (Record record in workbook.Records) { record.Write(writer); } writer.Close(); newDoc.WriteStreamData(new string[] { "Workbook" }, stream.ToArray()); } newDoc.Save(); } }
public void Save(Stream s) { BinaryWriter bw = new BinaryWriter(s); //Writing Column Naow int TotalRows = this.Worksheets[0].Cells.LastRowIndex; for (int i = TotalRows + 1; i < TotalRows + 50; i++) { for (int ColumnCount = 0; ColumnCount < 5; ColumnCount++) { this.Worksheets[0].Cells[i, ColumnCount] = new Cell(""); } } CompoundDocument doc = CompoundDocument.Create(s, bw); MemoryStream stream = new MemoryStream(); WorkbookEncoder.Encode(this, stream); doc.WriteStreamData(new string[] { "Workbook" }, stream.ToArray()); doc.Save(); doc.Close(); }