예제 #1
0
        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();
        }
예제 #2
0
        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();
            }
        }