internal void Save(ExcelPackage package, ZipPackagePart WorkbookPart, Uri personsUri)
 {
     if (Count == 0)
     {
         if (package.ZipPackage.PartExists(personsUri))
         {
             package.ZipPackage.DeletePart(personsUri);
         }
     }
     else
     {
         if (!package.ZipPackage.PartExists(personsUri))
         {
             var p = package.ZipPackage.CreatePart(personsUri, "application/vnd.ms-excel.person+xml");
             WorkbookPart.CreateRelationship(personsUri, Packaging.TargetMode.Internal, ExcelPackage.schemaPersonsRelationShips);
         }
         package.SavePart(personsUri, PersonsXml);
     }
 }
Пример #2
0
        internal ExcelXmlSource(ZipPackagePart relPart, string relId)
        {
            if (string.IsNullOrEmpty(relId))
            {
                Uri  = XmlHelper.GetNewUri(relPart.Package, "/xl/slicers/slicer{0}.xml");
                Part = relPart.Package.CreatePart(Uri, "application/vnd.ms-excel.slicer+xml", CompressionLevel.Default);
                Rel  = relPart.CreateRelationship(UriHelper.GetRelativeUri(relPart.Uri, Uri), TargetMode.Internal, ExcelPackage.schemaRelationshipsSlicer);
                var xml = new XmlDocument();
                XmlHelper.LoadXmlSafe(xml, "<slicers xmlns:xr10=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision10\" xmlns:x=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" mc:Ignorable=\"x xr10\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\" />", Encoding.UTF8);
                XmlDocument = xml;
            }
            else
            {
                Rel  = relPart.GetRelationship(relId);
                Uri  = UriHelper.ResolvePartUri(relPart.Uri, Rel.TargetUri);
                Part = relPart.Package.GetPart(Uri);

                var xml = new XmlDocument();
                XmlHelper.LoadXmlSafe(xml, Part.GetStream());
                XmlDocument = xml;
            }
        }