private void CreateDataSpaces(CompoundDocument doc) { var ds = new CompoundDocument.StoragePart(); doc.Storage.SubStorage.Add("\x06" + "DataSpaces", ds); var ver=new CompoundDocument.StoragePart(); ds.DataStreams.Add("Version", CreateVersionStream()); ds.DataStreams.Add("DataSpaceMap", CreateDataSpaceMap()); var dsInfo=new CompoundDocument.StoragePart(); ds.SubStorage.Add("DataSpaceInfo", dsInfo); dsInfo.DataStreams.Add("StrongEncryptionDataSpace", CreateStrongEncryptionDataSpaceStream()); var transInfo=new CompoundDocument.StoragePart(); ds.SubStorage.Add("TransformInfo", transInfo); var strEncTrans=new CompoundDocument.StoragePart(); transInfo.SubStorage.Add("StrongEncryptionTransform", strEncTrans); strEncTrans.DataStreams.Add("\x06Primary", CreateTransformInfoPrimary()); }
internal void Save() { if (Validate()) { CompoundDocument doc = new CompoundDocument(); doc.Storage = new CompoundDocument.StoragePart(); var store = new CompoundDocument.StoragePart(); doc.Storage.SubStorage.Add("VBA", store); store.DataStreams.Add("_VBA_PROJECT", CreateVBAProjectStream()); store.DataStreams.Add("dir", CreateDirStream()); foreach (var module in Modules) { store.DataStreams.Add(module.Name, CompoundDocument.CompressPart(Encoding.GetEncoding(CodePage).GetBytes(module.Attributes.GetAttributeText() + module.Code))); } //Copy streams from the template, if used. if (Document != null) { foreach (var ss in Document.Storage.SubStorage) { if (ss.Key != "VBA") { doc.Storage.SubStorage.Add(ss.Key, ss.Value); } } foreach (var s in Document.Storage.DataStreams) { if (s.Key != "dir" && s.Key != "PROJECT" && s.Key != "PROJECTwm") { doc.Storage.DataStreams.Add(s.Key, s.Value); } } } doc.Storage.DataStreams.Add("PROJECT", CreateProjectStream()); doc.Storage.DataStreams.Add("PROJECTwm", CreateProjectwmStream()); if (Part == null) { Uri = new Uri(PartUri, UriKind.Relative); Part = _pck.CreatePart(Uri, ExcelPackage.schemaVBA); var rel = _wb.Part.CreateRelationship(Uri, TargetMode.Internal, schemaRelVba); } var vbaBuffer=doc.Save(); var st = Part.GetStream(FileMode.Create); st.Write(vbaBuffer, 0, vbaBuffer.Length); st.Flush(); st.Close(); //Save the digital signture Signature.Save(this); } }