Example #1
0
        private void AddTableCommonProperty(GraphicFrame graphicFrame1, uint ObjectID)
        {
            NonVisualGraphicFrameProperties nonVisualGraphicFrameProperties1 = new NonVisualGraphicFrameProperties();

            NonVisualDrawingProperties nonVisualDrawingProperties2 = new NonVisualDrawingProperties()
            {
                Id = ObjectID, Name = $"Table{ObjectID}"
            };

            A.NonVisualDrawingPropertiesExtensionList nonVisualDrawingPropertiesExtensionList1 = new A.NonVisualDrawingPropertiesExtensionList();

            A.NonVisualDrawingPropertiesExtension nonVisualDrawingPropertiesExtension1 = new A.NonVisualDrawingPropertiesExtension()
            {
                Uri = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"
            };

            OpenXmlUnknownElement openXmlUnknownElement1 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<a16:creationId xmlns:a16=\"http://schemas.microsoft.com/office/drawing/2014/main\" id=\"{7AB8EDC7-F9EF-4752-9A46-413B9437344B}\" />");

            nonVisualDrawingPropertiesExtension1.Append(openXmlUnknownElement1);

            nonVisualDrawingPropertiesExtensionList1.Append(nonVisualDrawingPropertiesExtension1);

            nonVisualDrawingProperties2.Append(nonVisualDrawingPropertiesExtensionList1);

            NonVisualGraphicFrameDrawingProperties nonVisualGraphicFrameDrawingProperties1 = new NonVisualGraphicFrameDrawingProperties();

            A.GraphicFrameLocks graphicFrameLocks1 = new A.GraphicFrameLocks()
            {
                NoGrouping = true
            };

            nonVisualGraphicFrameDrawingProperties1.Append(graphicFrameLocks1);

            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties2 = new ApplicationNonVisualDrawingProperties();

            ApplicationNonVisualDrawingPropertiesExtensionList applicationNonVisualDrawingPropertiesExtensionList1 = new ApplicationNonVisualDrawingPropertiesExtensionList();

            ApplicationNonVisualDrawingPropertiesExtension applicationNonVisualDrawingPropertiesExtension1 = new ApplicationNonVisualDrawingPropertiesExtension()
            {
                Uri = "{D42A27DB-BD31-4B8C-83A1-F6EECF244321}"
            };

            P14.ModificationId modificationId1 = new P14.ModificationId()
            {
                Val = (UInt32Value)833561296U
            };
            modificationId1.AddNamespaceDeclaration("p14", "http://schemas.microsoft.com/office/powerpoint/2010/main");

            applicationNonVisualDrawingPropertiesExtension1.Append(modificationId1);

            applicationNonVisualDrawingPropertiesExtensionList1.Append(applicationNonVisualDrawingPropertiesExtension1);

            applicationNonVisualDrawingProperties2.Append(applicationNonVisualDrawingPropertiesExtensionList1);

            nonVisualGraphicFrameProperties1.Append(nonVisualDrawingProperties2);
            nonVisualGraphicFrameProperties1.Append(nonVisualGraphicFrameDrawingProperties1);
            nonVisualGraphicFrameProperties1.Append(applicationNonVisualDrawingProperties2);

            graphicFrame1.Append(nonVisualGraphicFrameProperties1);
        }
        public void CreateOpenXmlUnknownElmenentTest()
        {
            // Valid outer xml
            string validOuterXml = "<myElement  xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\"></myElement>";
            var    unknown1      = OpenXmlUnknownElement.CreateOpenXmlUnknownElement(validOuterXml);

            Assert.Equal(validOuterXml, unknown1.OuterXml);

            // Valid outer xml but starting with whitespace.
            string validOuterXmlWithWhitespaces = "   <myElement  xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\"></myElement>";
            var    unknown2 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement(validOuterXmlWithWhitespaces);

            Assert.Equal(validOuterXmlWithWhitespaces, unknown2.OuterXml);

            // Check bug #484153.
            string outerXmlWithXmlDecl = "<?xml version=\"1.0\" encoding=\"utf-8\"?><customUI  xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\"></customUI>";

            try
            {
                var unknown3 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement(outerXmlWithXmlDecl);
                Assert.True(false); // Assert.Fail("Expected InvalidOperationException is not thrown");
            }
            catch (ArgumentException ex1)
            {
                Assert.StartsWith(ExceptionMessages.InvalidOuterXml, ex1.Message);
            }
        }
        public void CloneUnknownElementTest()
        {
            string outerXml = "<a:txBody xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:p><a:r><a:t>Text in &lt;drawing&gt;.</a:t></a:r></a:p></a:txBody>";

            OpenXmlUnknownElement unknownElement = OpenXmlUnknownElement.CreateOpenXmlUnknownElement(outerXml);

            Assert.IsType <OpenXmlUnknownElement>(unknownElement.FirstChild);
            Assert.IsType <OpenXmlUnknownElement>(unknownElement.FirstChild.FirstChild);
            Assert.IsType <OpenXmlUnknownElement>(unknownElement.FirstChild.FirstChild.FirstChild);
            Assert.Equal("Text in <drawing>.", (unknownElement.FirstChild.FirstChild.FirstChild as OpenXmlUnknownElement).Text);

            Assert.Equal(outerXml, unknownElement.OuterXml);

            OpenXmlElement clonedElement = unknownElement.CloneNode(true);

            Assert.Equal("txBody", clonedElement.LocalName);
            Assert.Equal("a", clonedElement.Prefix);
            Assert.Equal("http://schemas.openxmlformats.org/drawingml/2006/main", clonedElement.NamespaceUri);
            Assert.IsType <OpenXmlUnknownElement>(clonedElement);

            Assert.IsType <OpenXmlUnknownElement>(clonedElement.FirstChild);
            Assert.IsType <OpenXmlUnknownElement>(clonedElement.FirstChild.FirstChild);
            Assert.IsType <OpenXmlUnknownElement>(clonedElement.FirstChild.FirstChild.FirstChild);
            Assert.Equal("Text in <drawing>.", (clonedElement.FirstChild.FirstChild.FirstChild as OpenXmlUnknownElement).Text);

            Assert.Equal(outerXml, clonedElement.OuterXml);

            clonedElement = unknownElement.CloneNode(false);

            Assert.Equal("txBody", clonedElement.LocalName);
            Assert.Equal("a", clonedElement.Prefix);
            Assert.Equal("http://schemas.openxmlformats.org/drawingml/2006/main", clonedElement.NamespaceUri);
            Assert.Null(clonedElement.FirstChild);
        }
Example #4
0
        public void InnerXmlTest()
        {
            var paragraphOuterXml = "<w:p w:rsidP=\"001\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:r><w:t>Run Text.</w:t><w:t>Run 2.</w:t></w:r></w:p>";
            var paragraphInnerXml = "<w:r xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:t>Run Text.</w:t><w:t>Run 2.</w:t></w:r>";
            var run1Text          = "Run Text.";
            var run2Text          = "Run 2.";

            var p = new Paragraph(new Run(new Text(run1Text), new Text(run2Text)));

            p.RsidParagraphProperties = "001";

            Assert.Equal(paragraphOuterXml, p.OuterXml);
            Assert.Equal(paragraphInnerXml, p.InnerXml);
            Assert.Equal(run1Text + run2Text, p.InnerText);

            var fontSize = new FontSize();

            fontSize.Val = "12"; // change from UInt64 to UInt32 according to deviation bug $14199

            Assert.Equal(string.Empty, fontSize.InnerXml);
            Assert.Equal(string.Empty, fontSize.InnerText);

            p          = new Paragraph();
            p.InnerXml = paragraphInnerXml;
            p.RsidParagraphProperties = "001";

            // make sure elements are fully populated.
            var r1 = p.FirstChild.FirstChild;
            var r2 = r1.NextSibling();

            Assert.Equal(run1Text, r1.InnerText);
            Assert.Equal(run2Text, r2.InnerText);

            var newOuter = "<w:p w:rsidP=\"001\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:r xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:t>Run Text.</w:t><w:t>Run 2.</w:t></w:r></w:p>";

            Assert.Equal(newOuter, p.OuterXml);
            Assert.Equal(paragraphInnerXml, p.InnerXml);
            Assert.Equal(run1Text + run2Text, p.InnerText);

            p = new Paragraph(paragraphOuterXml);

            // Since the element is initialized with outer xml, namespaces will already be tracked, and thus will be listed first
            var paragraphOuterXml2 = "<w:p xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" w:rsidP=\"001\"><w:r><w:t>Run Text.</w:t><w:t>Run 2.</w:t></w:r></w:p>";

            Assert.Equal(paragraphOuterXml2, p.OuterXml);
            Assert.Equal(paragraphInnerXml, p.InnerXml);
            Assert.Equal(run1Text + run2Text, p.InnerText);

            var unknownElement = OpenXmlUnknownElement.CreateOpenXmlUnknownElement(paragraphOuterXml);

            Assert.Equal(paragraphOuterXml2, unknownElement.OuterXml);
            Assert.Equal(paragraphInnerXml, unknownElement.InnerXml);
        }
Example #5
0
        public void AcbValidationTest()
        {
            MCContext           mcContext = new MCContext();
            ParagraphProperties pPr;
            Run       run1, run2;
            Paragraph p = new Paragraph(
                pPr = new ParagraphProperties()
            {
                WordWrap = new WordWrap()
                {
                    Val = true
                }
            },
                new OpenXmlMiscNode(System.Xml.XmlNodeType.Comment, "<!-- comments -->"),
                run1 = new Run(new Text("Text 1.")),
                run2 = new Run(new Text("Text 2.")));

            p.AddNamespaceDeclaration("w14test", "http://w14.com");

            OpenXmlUnknownElement ignorableElement = new OpenXmlUnknownElement("w14test", "span", "http://w14.com");

            ignorableElement.MCAttributes = new MarkupCompatibilityAttributes()
            {
                Ignorable = "w14test"
            };
            p.InsertAfter(ignorableElement, pPr);

            Run runInAcb         = new Run(new Text("Text in ACB."));
            Run run2InAcb        = new Run(new Text("Text 2 in ACB."));
            AlternateContent acb = new AlternateContent(
                new AlternateContentChoice()
            {
                Requires = "w14test"
            },
                new AlternateContentFallback(runInAcb, run2InAcb));

            p.InsertAfter(acb, pPr);

            var validator = new OpenXmlValidator();
            var errors    = validator.Validate(p);

            Assert.Empty(errors);

            p.AppendChild(new OpenXmlUnknownElement("w15test", "art", "http://w15.com"));
            errors = validator.Validate(p);
            Assert.Single(errors);
            p.RemoveChild(p.LastChild);

            acb.LastChild.Append(new OpenXmlUnknownElement("w15test", "art", "http://w15.com"));
            errors = validator.Validate(p);
            Assert.Single(errors);
        }
Example #6
0
        public void TwiceCallsToLoadAttributeOnUnknown()
        {
            var rawxml = @"<dgm14:cNvPr xmlns:dgm14=""http://schemas.microsoft.com/officeart/2007/7/20/diagram"" id=""0"" name="""" />";
            var ele    = OpenXmlUnknownElement.CreateOpenXmlUnknownElement(rawxml);

            Log.VerifyTrue(ele.GetAttributes().Count == 2, "ele.GetAttributes().Count"); // The count should be 2 as now namespace declaration is not considered as attribute.
            Log.VerifyTrue(ele.OuterXml == rawxml, "ele.OuterXml");

            var clone = ele.Clone() as OpenXmlUnknownElement;

            Log.VerifyTrue(clone.GetAttributes().Count == 2, "clone.GetAttributes().Count");
            Log.VerifyTrue(clone.OuterXml == rawxml, "clone.OuterXml");
        }
        public void InnerXmlTest()
        {
            string paragraphOuterXml = "<w:p w:rsidP=\"001\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:r><w:t>Run Text.</w:t><w:t>Run 2.</w:t></w:r></w:p>";
            string paragraphInnerXml = "<w:r xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:t>Run Text.</w:t><w:t>Run 2.</w:t></w:r>";
            string run1Text          = "Run Text.";
            string run2Text          = "Run 2.";

            Paragraph p = new Paragraph(new Run(new Text(run1Text), new Text(run2Text)));

            p.RsidParagraphProperties = "001";

            Assert.Equal(paragraphOuterXml, p.OuterXml);
            Assert.Equal(paragraphInnerXml, p.InnerXml);
            Assert.Equal(run1Text + run2Text, p.InnerText);

            FontSize fontSize = new FontSize();

            fontSize.Val = "12"; // change from UInt64 to UInt32 according to deviation bug $14199

            Assert.Equal(string.Empty, fontSize.InnerXml);
            Assert.Equal(string.Empty, fontSize.InnerText);

            p          = new Paragraph();
            p.InnerXml = paragraphInnerXml;
            p.RsidParagraphProperties = "001";

            // make sure elements are fully populated.
            var r1 = p.FirstChild.FirstChild;
            var r2 = r1.NextSibling();

            Assert.Equal(run1Text, r1.InnerText);
            Assert.Equal(run2Text, r2.InnerText);

            var newOuter = "<w:p w:rsidP=\"001\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:r xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:t>Run Text.</w:t><w:t>Run 2.</w:t></w:r></w:p>";

            Assert.Equal(newOuter, p.OuterXml);
            Assert.Equal(paragraphInnerXml, p.InnerXml);
            Assert.Equal(run1Text + run2Text, p.InnerText);

            p = new Paragraph(paragraphOuterXml);
            Assert.Equal(paragraphOuterXml, p.OuterXml);
            Assert.Equal(paragraphInnerXml, p.InnerXml);
            Assert.Equal(run1Text + run2Text, p.InnerText);

            OpenXmlUnknownElement unknownElement = OpenXmlUnknownElement.CreateOpenXmlUnknownElement(paragraphOuterXml);

            Assert.Equal(paragraphOuterXml, unknownElement.OuterXml);
            Assert.Equal(paragraphInnerXml, unknownElement.InnerXml);
        }
Example #8
0
        private void GenerateWorkbookPartContent(WorkbookPart workbookPart)
        {
            Workbook workbook = new Workbook()
            {
                MCAttributes = new MarkupCompatibilityAttributes()
                {
                    Ignorable = "x15 xr xr6 xr10 xr2"
                }
            };

            workbook.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            workbook.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            workbook.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
            workbook.AddNamespaceDeclaration("xr", "http://schemas.microsoft.com/office/spreadsheetml/2014/revision");
            workbook.AddNamespaceDeclaration("xr6", "http://schemas.microsoft.com/office/spreadsheetml/2016/revision6");
            workbook.AddNamespaceDeclaration("xr10", "http://schemas.microsoft.com/office/spreadsheetml/2016/revision10");
            workbook.AddNamespaceDeclaration("xr2", "http://schemas.microsoft.com/office/spreadsheetml/2015/revision2");

            OpenXmlUnknownElement openXmlUnknownElement2 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<xr:revisionPtr revIDLastSave=\"0\" documentId=\"13_ncr:1_{430224E7-E52E-4CB2-AD4B-D26B961B38B6}\" xr6:coauthVersionLast=\"45\" xr6:coauthVersionMax=\"45\" xr10:uidLastSave=\"{00000000-0000-0000-0000-000000000000}\" xmlns:xr10=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision10\" xmlns:xr6=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision6\" xmlns:xr=\"http://schemas.microsoft.com/office/spreadsheetml/2014/revision\" />");

            Sheets sheets = new Sheets();
            Sheet  sheet  = new Sheet()
            {
                Name = SheetName, SheetId = (UInt32Value)1U, Id = "rId1"
            };

            sheets.Append(sheet);

            WorkbookExtensionList workbookExtensionList = new WorkbookExtensionList();

            WorkbookExtension workbookExtension1 = new WorkbookExtension()
            {
                Uri = "{140A7094-0E35-4892-8432-C4D2E57EDEB5}"
            };

            workbookExtension1.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");

            OpenXmlUnknownElement openXmlUnknownElement3 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<x15:workbookPr chartTrackingRefBase=\"1\" xmlns:x15=\"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main\" />");

            workbookExtension1.Append(openXmlUnknownElement3);
            workbookExtensionList.Append(workbookExtension1);

            workbook.Append(openXmlUnknownElement2);
            workbook.Append(sheets);
            workbook.Append(workbookExtensionList);

            workbookPart.Workbook = workbook;
        }
        public void NamespaceDeclarationForNewUnknownElement()
        {
            this.MyTestInitialize(TestContext.GetCurrentMethod());
            var testfiles = CopyTestFiles(@"bvt")
                            .Where(fi => fi.IsOpenXmlFile());

            System.Uri partUri;
            string     hostPath;
            var        prefix       = "uns";
            var        localname    = "unknownEle";
            var        namespaceUri = @"http://test.openxmlsdk.microsoft.com/unknownns1";

            foreach (FileInfo testfile in testfiles)
            {
                Log.BeginGroup(testfile.Name);

                using (var package = testfile.OpenPackage(true, true))
                {
                    var part = package.DescendantParts().Where(p => p.IsReflectable()).FirstOrDefault();
                    partUri = part.Uri;
                    var dom  = part.RootElement;
                    var host = dom.Descendants <OpenXmlCompositeElement>().PickSecond();
                    hostPath = host.Path();

                    var unknown = new OpenXmlUnknownElement(prefix, localname, namespaceUri);
                    unknown = host.AppendChild(unknown);
                    KeyValuePair <string, string> ns = unknown.NamespaceDeclarations.Where(kvp => kvp.Key == prefix && kvp.Value == namespaceUri).FirstOrDefault();
                    if (ns.Key == null)
                    {
                        ns = new KeyValuePair <string, string>(unknown.Prefix, unknown.NamespaceUri);
                    }

                    Log.VerifyTrue(ns.Key == prefix && ns.Value == namespaceUri, "NO namespace declarations matches found.");
                }

                using (var package = testfile.OpenPackage(false, false))
                {
                    var part = package.DescendantParts().Where(p => p.IsReflectable() && p.Uri == partUri).FirstOrDefault();
                    var dom  = part.RootElement;
                    var host = dom.Descendants <OpenXmlCompositeElement>().Where(d => d.Path() == hostPath).FirstOrDefault();

                    var unknown = host.LastChild;
                    var ns      = unknown.NamespaceDeclarations.Where(kvp => kvp.Key == prefix && kvp.Value == namespaceUri);
                    Log.VerifyTrue(ns.FirstOrDefault().Key == prefix && ns.FirstOrDefault().Value == namespaceUri, "NO namespace declarations matches found.");
                }
            }
        }
Example #10
0
        public void NamespaceDeclarationForNewUnknownElement(string path)
        {
            Uri    partUri;
            string hostPath;
            var    prefix       = "uns";
            var    localname    = "unknownEle";
            var    namespaceUri = @"http://test.openxmlsdk.microsoft.com/unknownns1";

            using (var testfile = OpenFile(path, true))
            {
                using (var package = testfile.Open(true))
                {
                    var part = package.DescendantParts().Where(p => p.IsReflectable()).FirstOrDefault();
                    partUri = part.Uri;
                    var dom  = part.RootElement;
                    var host = dom.Descendants <OpenXmlCompositeElement>().PickSecond();
                    hostPath = host.Path();

                    var unknown = new OpenXmlUnknownElement(prefix, localname, namespaceUri);
                    unknown = host.AppendChild(unknown);
                    var ns = unknown.NamespaceDeclarations.Where(kvp => kvp.Key == prefix && kvp.Value == namespaceUri).FirstOrDefault();

                    if (ns.Key is null)
                    {
                        ns = new KeyValuePair <string, string>(unknown.Prefix, unknown.NamespaceUri);
                    }

                    Assert.Equal(prefix, ns.Key);
                    Assert.Equal(namespaceUri, ns.Value);
                }

                using (var package = testfile.Open(false))
                {
                    var part = package.DescendantParts().Where(p => p.IsReflectable() && p.Uri == partUri).FirstOrDefault();
                    var dom  = part.RootElement;
                    var host = dom.Descendants <OpenXmlCompositeElement>().Where(d => d.Path() == hostPath).FirstOrDefault();

                    var unknown = host.LastChild;
                    var ns      = unknown.NamespaceDeclarations.Where(kvp => kvp.Key == prefix && kvp.Value == namespaceUri);

                    Assert.Equal(prefix, ns.FirstOrDefault().Key);
                    Assert.Equal(namespaceUri, ns.FirstOrDefault().Value);
                }
            }
        }
Example #11
0
        public void CreateOpenXmlUnknownElmenentTest()
        {
            // Valid outer xml
            var validOuterXml = "<myElement  xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\"></myElement>";
            var unknown1      = OpenXmlUnknownElement.CreateOpenXmlUnknownElement(validOuterXml);

            Assert.Equal(validOuterXml, unknown1.OuterXml);

            // Valid outer xml but starting with whitespace.
            var validOuterXmlWithWhitespaces = "   <myElement  xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\"></myElement>";
            var unknown2 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement(validOuterXmlWithWhitespaces);

            Assert.Equal(validOuterXmlWithWhitespaces, unknown2.OuterXml);

            // Check bug #484153.
            var outerXmlWithXmlDecl = "<?xml version=\"1.0\" encoding=\"utf-8\"?><customUI  xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\"></customUI>";
            var ex1 = Assert.Throws <ArgumentException>(() => OpenXmlUnknownElement.CreateOpenXmlUnknownElement(outerXmlWithXmlDecl));

            Assert.StartsWith(ExceptionMessages.InvalidOuterXml, ex1.Message);
        }
        private void SetCustomXmlMappings(SpreadsheetDocument document)
        {
            var customXmlMappingsPart = document.WorkbookPart.AddNewPart <CustomXmlMappingsPart>(NewId());
            var mapInfo = new MapInfo {
                SelectionNamespaces = ""
            };

            var schema = new Schema {
                Id = SchemaId
            };

            var xmlSchemaElement = OpenXmlUnknownElement.CreateOpenXmlUnknownElement(_xmlSchema);

            schema.AppendChild(xmlSchemaElement);

            var map = new Map
            {
                ID                      = MapId,
                Name                    = _metadata.Name,
                RootElement             = RootElementName,
                SchemaId                = SchemaId,
                ShowImportExportErrors  = false,
                AutoFit                 = true,
                AppendData              = false,
                PreserveAutoFilterState = true,
                PreserveFormat          = true
            };

            var dataBinding = new DataBinding
            {
                FileBinding         = true,
                ConnectionId        = ConnectionId,
                DataBindingLoadMode = 1U
            };

            map.AppendChild(dataBinding);
            mapInfo.AppendChild(schema);
            mapInfo.AppendChild(map);

            customXmlMappingsPart.MapInfo = _applyHack(mapInfo);
        }
Example #13
0
        private static void AddNewGridColumn(OpenXmlElement tableGrid, OpenXmlElement headerRow, OpenXmlElement contentRow)
        {
            var columns = tableGrid.Descendants <OXD.GridColumn>().ToList();

            if (columns.Count == 0 || !columns.Any())
            {
                return;
            }
            var    headerLastCell  = headerRow.Descendants <OXD.TableCell>().Last();
            var    contentLastCell = contentRow.Descendants <OXD.TableCell>().Last();
            double tableWidth      = columns.Sum(_ => Convert.ToInt32(_.Width.Value));
            var    newColWidth     = Math.Floor(tableWidth / columns.Count);

            foreach (var col in columns)
            {
                col.Width = col.Width > 0 ? Convert.ToInt64(Math.Floor((tableWidth - newColWidth) / (tableWidth / col.Width))) : 0;
            }

            OXD.GridColumn newcol = new OXD.GridColumn()
            {
                Width = Convert.ToInt64(newColWidth)
            };
            OXD.ExtensionList init_extlst = newcol.Descendants <OXD.ExtensionList>().FirstOrDefault();
            if (init_extlst != null)
            {
                OXD.Extension         init_ext   = init_extlst.Descendants <OXD.Extension>().FirstOrDefault();
                OpenXmlUnknownElement init_colId = init_ext?.GetFirstChild <OpenXmlUnknownElement>();
                OpenXmlUnknownElement new_colId  = init_colId?.CloneNode(true) as OpenXmlUnknownElement;
                if (new_colId != null)
                {
                    OpenXmlAttribute val = new_colId.GetAttributes().FirstOrDefault();
                    val.Value = new Random().Next().ToString();
                    new_colId.SetAttribute(val);
                    init_ext.ReplaceChild(new_colId, init_colId);
                }
            }
            tableGrid.InsertAfter(newcol, columns.Last());
            headerRow.InsertAfter((OXD.TableCell)headerLastCell.CloneNode(true), headerLastCell);
            contentRow.InsertAfter((OXD.TableCell)contentLastCell.CloneNode(true), contentLastCell);
        }
Example #14
0
        public void GetChildMcTest()
        {
            MCContext           mcContext = new MCContext();
            ParagraphProperties pPr;
            Run       run1, run2;
            Paragraph p = new Paragraph(
                pPr = new ParagraphProperties()
            {
                WordWrap = new WordWrap()
                {
                    Val = true
                }
            },
                new OpenXmlMiscNode(System.Xml.XmlNodeType.Comment, "<!-- comments -->"),
                run1 = new Run(new Text("Text 1.")),
                run2 = new Run(new Text("Text 2.")));

            var target = p.GetFirstChildMc(mcContext, FileFormatVersions.Office2007);

            Assert.Same(pPr, target);
            target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007);
            Assert.Same(run1, target);
            target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007);
            Assert.Same(run2, target);

            OpenXmlUnknownElement ignorableElement = new OpenXmlUnknownElement("w14test", "span", "http://w14.com");

            p.AddNamespaceDeclaration("w14test", "http://w14.com");

            ignorableElement.MCAttributes = new MarkupCompatibilityAttributes()
            {
                Ignorable = "w14test"
            };
            p.InsertAfter(ignorableElement, pPr);

            mcContext = new MCContext();
            target    = p.GetFirstChildMc(mcContext, FileFormatVersions.Office2007);
            Assert.Same(pPr, target);
            target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007);
            Assert.Same(run1, target);
            target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007);
            Assert.Same(run2, target);

            Run runInAcb         = new Run(new Text("Text in ACB."));
            AlternateContent acb = new AlternateContent(
                new AlternateContentChoice()
            {
                Requires = "w14test"
            },
                new AlternateContentFallback(runInAcb));

            p.InsertAfter(acb, pPr);

            mcContext = new MCContext();
            target    = p.GetFirstChildMc(mcContext, FileFormatVersions.Office2007);
            Assert.Same(pPr, target);
            target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007);
            Assert.Same(runInAcb, target);
            target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007);
            Assert.Same(run1, target);
            target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007);
            Assert.Same(run2, target);
        }
Example #15
0
        //private void AddContent(ShapeTree shapeTree1, uint ObjectID, PPTXTextArea Content, PlaceholderValues PlaceHolderType, uint PlaceHolderIndex = uint.MaxValue)
        //{
        //    Shape shape1 = new Shape();

        //    NonVisualShapeProperties nonVisualShapeProperties1 = new NonVisualShapeProperties();

        //    NonVisualDrawingProperties nonVisualDrawingProperties2 = new NonVisualDrawingProperties() { Id = ObjectID, Name = $"Content{ObjectID}" };

        //    NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties1 = new NonVisualShapeDrawingProperties() { TextBox = true};
        //    A.ShapeLocks shapeLocks1 = new A.ShapeLocks() { NoGrouping = true };

        //    nonVisualShapeDrawingProperties1.Append(shapeLocks1);

        //    ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties2 = new ApplicationNonVisualDrawingProperties();
        //    PlaceholderShape placeholderShape1 = new PlaceholderShape();// { Type = PlaceHolderType };
        //    if (PlaceHolderIndex != uint.MaxValue)
        //    {
        //        placeholderShape1.Index = PlaceHolderIndex;
        //    }

        //    applicationNonVisualDrawingProperties2.Append(placeholderShape1);

        //    nonVisualShapeProperties1.Append(nonVisualDrawingProperties2);
        //    nonVisualShapeProperties1.Append(nonVisualShapeDrawingProperties1);
        //    nonVisualShapeProperties1.Append(applicationNonVisualDrawingProperties2);
        //    ShapeProperties shapeProperties1 = new ShapeProperties();

        //    A.SolidFill solidFill1 = new A.SolidFill();

        //    A.SchemeColor schemeColor1 = new A.SchemeColor() { Val = A.SchemeColorValues.Accent1 };
        //    A.LuminanceModulation luminanceModulation1 = new A.LuminanceModulation() { Val = 20000 };
        //    A.LuminanceOffset luminanceOffset1 = new A.LuminanceOffset() { Val = 80000 };

        //    schemeColor1.Append(luminanceModulation1);
        //    schemeColor1.Append(luminanceOffset1);

        //    solidFill1.Append(schemeColor1);

        //    shapeProperties1.Append(solidFill1);

        //    TextBody textBody1 = new TextBody();
        //    A.BodyProperties bodyProperties1 = new A.BodyProperties();
        //    A.ListStyle listStyle1 = new A.ListStyle();

        //    textBody1.Append(bodyProperties1);
        //    textBody1.Append(listStyle1);

        //    A.Transform2D transform2D25 = SlideWriterHelper.CreateTransform2D(Content.Transform);
        //    if (transform2D25 != null)
        //    {
        //        shapeProperties1.Append(transform2D25);
        //    }

        //    shape1.Append(nonVisualShapeProperties1);
        //    shape1.Append(shapeProperties1);
        //    shape1.Append(textBody1);

        //    foreach (var _textLine in Content.Texts)
        //    {
        //        var paragraph = new A.Paragraph(SlideWriterHelper.CrateParagraphProperties(_textLine));

        //        foreach(var _textRun in _textLine.Texts)
        //        {
        //            paragraph.Append(new A.Run()
        //            {
        //                RunProperties = SlideWriterHelper.CreateRunProperties(_textRun, HyperLinkIDMap),
        //                Text = new A.Text(_textRun.Text)
        //            });
        //        }

        //        shape1.TextBody.Append(paragraph);
        //    }

        //    shapeTree1.Append(shape1);
        //}


        private void AddTextBox(ShapeTree shapeTree1, uint ObjectID, PPTXTextArea Content)
        {
            Shape shape1 = new Shape();

            NonVisualShapeProperties nonVisualShapeProperties1 = new NonVisualShapeProperties();

            NonVisualDrawingProperties nonVisualDrawingProperties2 = new NonVisualDrawingProperties()
            {
                Id = ObjectID, Name = $"Content{ObjectID}"
            };

            A.NonVisualDrawingPropertiesExtensionList nonVisualDrawingPropertiesExtensionList1 = new A.NonVisualDrawingPropertiesExtensionList();

            A.NonVisualDrawingPropertiesExtension nonVisualDrawingPropertiesExtension1 = new A.NonVisualDrawingPropertiesExtension()
            {
                Uri = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"
            };

            OpenXmlUnknownElement openXmlUnknownElement1 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<a16:creationId xmlns:a16=\"http://schemas.microsoft.com/office/drawing/2014/main\" id=\"{5FE2CA47-E73A-450F-9AE0-DF438874E2FB}\" />");

            nonVisualDrawingPropertiesExtension1.Append(openXmlUnknownElement1);

            nonVisualDrawingPropertiesExtensionList1.Append(nonVisualDrawingPropertiesExtension1);

            nonVisualDrawingProperties2.Append(nonVisualDrawingPropertiesExtensionList1);
            NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties1 = new NonVisualShapeDrawingProperties()
            {
                TextBox = true
            };
            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties2 = new ApplicationNonVisualDrawingProperties();

            nonVisualShapeProperties1.Append(nonVisualDrawingProperties2);
            nonVisualShapeProperties1.Append(nonVisualShapeDrawingProperties1);
            nonVisualShapeProperties1.Append(applicationNonVisualDrawingProperties2);

            ShapeProperties shapeProperties1 = new ShapeProperties();


            A.PresetGeometry presetGeometry1 = new A.PresetGeometry()
            {
                Preset = A.ShapeTypeValues.Rectangle
            };
            A.AdjustValueList adjustValueList1 = new A.AdjustValueList();

            presetGeometry1.Append(adjustValueList1);

            TextBody textBody1 = new TextBody();

            A.BodyProperties bodyProperties1 = new A.BodyProperties();
            A.ListStyle      listStyle1      = new A.ListStyle();

            textBody1.Append(bodyProperties1);
            textBody1.Append(listStyle1);

            A.Transform2D transform2D25 = SlideWriterHelper.CreateTransform2D(Content.Transform);
            if (transform2D25 != null)
            {
                shapeProperties1.Append(transform2D25);
            }

            shapeProperties1.Append(presetGeometry1);

            if (Content.BackgroundColor.IsTransparent == false)
            {
                A.SolidFill solidFill1 = new A.SolidFill();
                solidFill1.Append(SlideWriterHelper.CreateRGBColorModeHex(Content.BackgroundColor));
                shapeProperties1.Append(solidFill1);
            }


            shape1.Append(nonVisualShapeProperties1);
            shape1.Append(shapeProperties1);
            shape1.Append(textBody1);

            foreach (var _textLine in Content.Texts)
            {
                var paragraph = new A.Paragraph(SlideWriterHelper.CrateParagraphProperties(_textLine));

                foreach (var _textRun in _textLine.Texts)
                {
                    paragraph.Append(new A.Run()
                    {
                        RunProperties = SlideWriterHelper.CreateRunProperties(_textRun, HyperLinkIDMap),
                        Text          = new A.Text(_textRun.Text)
                    });
                }

                shape1.TextBody.Append(paragraph);
            }

            shapeTree1.Append(shape1);
        }
Example #16
0
        private static void GenerateSlidePart1Content(SlidePart slidePart1, string Title, string SubTitle)
        {
            Slide slide1 = new Slide();

            slide1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
            slide1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            slide1.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main");

            CommonSlideData commonSlideData1 = new CommonSlideData();

            ShapeTree shapeTree1 = new ShapeTree();

            NonVisualGroupShapeProperties nonVisualGroupShapeProperties1 = new NonVisualGroupShapeProperties();
            NonVisualDrawingProperties    nonVisualDrawingProperties1    = new NonVisualDrawingProperties()
            {
                Id = (UInt32Value)1U, Name = ""
            };
            NonVisualGroupShapeDrawingProperties  nonVisualGroupShapeDrawingProperties1  = new NonVisualGroupShapeDrawingProperties();
            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties1 = new ApplicationNonVisualDrawingProperties();

            nonVisualGroupShapeProperties1.Append(nonVisualDrawingProperties1);
            nonVisualGroupShapeProperties1.Append(nonVisualGroupShapeDrawingProperties1);
            nonVisualGroupShapeProperties1.Append(applicationNonVisualDrawingProperties1);

            GroupShapeProperties groupShapeProperties1 = new GroupShapeProperties();

            A.TransformGroup transformGroup1 = new A.TransformGroup();
            A.Offset         offset1         = new A.Offset()
            {
                X = 0L, Y = 0L
            };
            A.Extents extents1 = new A.Extents()
            {
                Cx = 0L, Cy = 0L
            };
            A.ChildOffset childOffset1 = new A.ChildOffset()
            {
                X = 0L, Y = 0L
            };
            A.ChildExtents childExtents1 = new A.ChildExtents()
            {
                Cx = 0L, Cy = 0L
            };

            transformGroup1.Append(offset1);
            transformGroup1.Append(extents1);
            transformGroup1.Append(childOffset1);
            transformGroup1.Append(childExtents1);

            groupShapeProperties1.Append(transformGroup1);

            Shape shape1 = new Shape();

            NonVisualShapeProperties nonVisualShapeProperties1 = new NonVisualShapeProperties();

            NonVisualDrawingProperties nonVisualDrawingProperties2 = new NonVisualDrawingProperties()
            {
                Id = (UInt32Value)4U, Name = "タイトル 3"
            };

            A.NonVisualDrawingPropertiesExtensionList nonVisualDrawingPropertiesExtensionList1 = new A.NonVisualDrawingPropertiesExtensionList();

            A.NonVisualDrawingPropertiesExtension nonVisualDrawingPropertiesExtension1 = new A.NonVisualDrawingPropertiesExtension()
            {
                Uri = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"
            };

            OpenXmlUnknownElement openXmlUnknownElement1 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<a16:creationId xmlns:a16=\"http://schemas.microsoft.com/office/drawing/2014/main\" id=\"{D363C360-A613-482D-ABFE-96D29918ABD2}\" />");

            nonVisualDrawingPropertiesExtension1.Append(openXmlUnknownElement1);

            nonVisualDrawingPropertiesExtensionList1.Append(nonVisualDrawingPropertiesExtension1);

            nonVisualDrawingProperties2.Append(nonVisualDrawingPropertiesExtensionList1);

            NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties1 = new NonVisualShapeDrawingProperties();

            A.ShapeLocks shapeLocks1 = new A.ShapeLocks()
            {
                NoGrouping = true
            };

            nonVisualShapeDrawingProperties1.Append(shapeLocks1);

            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties2 = new ApplicationNonVisualDrawingProperties();
            PlaceholderShape placeholderShape1 = new PlaceholderShape()
            {
                Type = PlaceholderValues.CenteredTitle
            };

            applicationNonVisualDrawingProperties2.Append(placeholderShape1);

            nonVisualShapeProperties1.Append(nonVisualDrawingProperties2);
            nonVisualShapeProperties1.Append(nonVisualShapeDrawingProperties1);
            nonVisualShapeProperties1.Append(applicationNonVisualDrawingProperties2);
            ShapeProperties shapeProperties1 = new ShapeProperties();

            TextBody textBody1 = new TextBody();

            A.BodyProperties bodyProperties1 = new A.BodyProperties();
            A.ListStyle      listStyle1      = new A.ListStyle();

            A.Paragraph paragraph1 = new A.Paragraph();

            A.Run           run1           = new A.Run();
            A.RunProperties runProperties1 = new A.RunProperties()
            {
                Kumimoji = true, Language = "ja-JP", AlternativeLanguage = "en-US", Dirty = false
            };
            A.Text text1 = new A.Text();
            text1.Text = Title;

            run1.Append(runProperties1);
            run1.Append(text1);

            paragraph1.Append(run1);

            textBody1.Append(bodyProperties1);
            textBody1.Append(listStyle1);
            textBody1.Append(paragraph1);

            shape1.Append(nonVisualShapeProperties1);
            shape1.Append(shapeProperties1);
            shape1.Append(textBody1);

            Shape shape2 = new Shape();

            NonVisualShapeProperties nonVisualShapeProperties2 = new NonVisualShapeProperties();

            NonVisualDrawingProperties nonVisualDrawingProperties3 = new NonVisualDrawingProperties()
            {
                Id = (UInt32Value)5U, Name = "字幕 4"
            };

            A.NonVisualDrawingPropertiesExtensionList nonVisualDrawingPropertiesExtensionList2 = new A.NonVisualDrawingPropertiesExtensionList();

            A.NonVisualDrawingPropertiesExtension nonVisualDrawingPropertiesExtension2 = new A.NonVisualDrawingPropertiesExtension()
            {
                Uri = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"
            };

            OpenXmlUnknownElement openXmlUnknownElement2 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<a16:creationId xmlns:a16=\"http://schemas.microsoft.com/office/drawing/2014/main\" id=\"{6CE3DF81-72AF-4DA1-B4EE-02B2D45D0AF8}\" />");

            nonVisualDrawingPropertiesExtension2.Append(openXmlUnknownElement2);

            nonVisualDrawingPropertiesExtensionList2.Append(nonVisualDrawingPropertiesExtension2);

            nonVisualDrawingProperties3.Append(nonVisualDrawingPropertiesExtensionList2);

            NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties2 = new NonVisualShapeDrawingProperties();

            A.ShapeLocks shapeLocks2 = new A.ShapeLocks()
            {
                NoGrouping = true
            };

            nonVisualShapeDrawingProperties2.Append(shapeLocks2);

            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties3 = new ApplicationNonVisualDrawingProperties();
            PlaceholderShape placeholderShape2 = new PlaceholderShape()
            {
                Type = PlaceholderValues.SubTitle, Index = (UInt32Value)1U
            };

            applicationNonVisualDrawingProperties3.Append(placeholderShape2);

            nonVisualShapeProperties2.Append(nonVisualDrawingProperties3);
            nonVisualShapeProperties2.Append(nonVisualShapeDrawingProperties2);
            nonVisualShapeProperties2.Append(applicationNonVisualDrawingProperties3);
            ShapeProperties shapeProperties2 = new ShapeProperties();

            TextBody textBody2 = new TextBody();

            A.BodyProperties bodyProperties2 = new A.BodyProperties();
            A.ListStyle      listStyle2      = new A.ListStyle();

            A.Paragraph paragraph2 = new A.Paragraph();

            A.Run           run2           = new A.Run();
            A.RunProperties runProperties2 = new A.RunProperties()
            {
                Kumimoji = true, Language = "ja-JP", AlternativeLanguage = "en-US"
            };
            A.Text text2 = new A.Text();
            text2.Text = SubTitle;

            run2.Append(runProperties2);
            run2.Append(text2);

            paragraph2.Append(run2);

            textBody2.Append(bodyProperties2);
            textBody2.Append(listStyle2);
            textBody2.Append(paragraph2);

            shape2.Append(nonVisualShapeProperties2);
            shape2.Append(shapeProperties2);
            shape2.Append(textBody2);

            shapeTree1.Append(nonVisualGroupShapeProperties1);
            shapeTree1.Append(groupShapeProperties1);
            shapeTree1.Append(shape1);
            shapeTree1.Append(shape2);

            CommonSlideDataExtensionList commonSlideDataExtensionList1 = new CommonSlideDataExtensionList();

            CommonSlideDataExtension commonSlideDataExtension1 = new CommonSlideDataExtension()
            {
                Uri = "{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}"
            };

            P14.CreationId creationId1 = new P14.CreationId()
            {
                Val = (UInt32Value)958156500U
            };
            creationId1.AddNamespaceDeclaration("p14", "http://schemas.microsoft.com/office/powerpoint/2010/main");

            commonSlideDataExtension1.Append(creationId1);

            commonSlideDataExtensionList1.Append(commonSlideDataExtension1);

            commonSlideData1.Append(shapeTree1);
            commonSlideData1.Append(commonSlideDataExtensionList1);

            ColorMapOverride colorMapOverride1 = new ColorMapOverride();

            A.MasterColorMapping masterColorMapping1 = new A.MasterColorMapping();

            colorMapOverride1.Append(masterColorMapping1);

            slide1.Append(commonSlideData1);
            slide1.Append(colorMapOverride1);

            slidePart1.Slide = slide1;
        }
Example #17
0
        /// <summary>
        /// Создает стилевую составляющую документа
        /// </summary>
        /// <param name="workbookStylesPart">Стилевая часть книги</param>
        private void GenerateStyles(WorkbookStylesPart workbookStylesPart)
        {
            Stylesheet stylesheet = new Stylesheet()
            {
                MCAttributes = new MarkupCompatibilityAttributes()
                {
                    Ignorable = "x14ac"
                }
            };

            stylesheet.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            stylesheet.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac");

            #region Fonts
            Fonts fonts = new Fonts()
            {
                Count      = 1U,
                KnownFonts = true
            };
            Font     font     = new Font();
            FontSize fontSize = new FontSize()
            {
                Val = 11D
            };
            Color color1 = new Color()
            {
                Theme = 1U
            };
            FontName fontName = new FontName()
            {
                Val = "Calibri"
            };
            FontFamilyNumbering fontFamilyNumbering = new FontFamilyNumbering()
            {
                Val = 2
            };
            FontCharSet fontCharSet = new FontCharSet()
            {
                Val = 204
            };
            FontScheme fontScheme = new FontScheme()
            {
                Val = FontSchemeValues.Minor
            };

            font.Append(fontSize);
            font.Append(color1);
            font.Append(fontName);
            font.Append(fontFamilyNumbering);
            font.Append(fontCharSet);
            font.Append(fontScheme);

            fonts.Append(font);
            #endregion

            #region Fills
            Fills fills = new Fills()
            {
                Count = 2U
            };

            Fill        fill1        = new Fill();
            PatternFill patternFill1 = new PatternFill()
            {
                PatternType = PatternValues.None
            };
            fill1.Append(patternFill1);

            Fill        fill2        = new Fill();
            PatternFill patternFill2 = new PatternFill()
            {
                PatternType = PatternValues.Gray125
            };
            fill2.Append(patternFill2);

            fills.Append(fill1);
            fills.Append(fill2);
            #endregion

            #region Borders
            Borders borders = new Borders()
            {
                Count = 1U
            };

            Border         border1         = new Border();
            LeftBorder     leftBorder1     = new LeftBorder();
            RightBorder    rightBorder1    = new RightBorder();
            TopBorder      topBorder1      = new TopBorder();
            BottomBorder   bottomBorder    = new BottomBorder();
            DiagonalBorder diagonalBorder1 = new DiagonalBorder();

            border1.Append(leftBorder1);
            border1.Append(rightBorder1);
            border1.Append(topBorder1);
            border1.Append(bottomBorder);
            border1.Append(diagonalBorder1);

            borders.Append(border1);
            #endregion

            #region Cell Styles And Formats
            CellStyleFormats cellStyleFormats = new CellStyleFormats()
            {
                Count = 1U
            };
            CellFormat cellFormat1 = new CellFormat()
            {
                NumberFormatId = 0U,
                FontId         = 0U,
                FillId         = 0U,
                BorderId       = 0U
            };
            cellStyleFormats.Append(cellFormat1);

            CellFormats cellFormats = new CellFormats()
            {
                Count = 1U
            };
            CellFormat cellFormat2 = new CellFormat()
            {
                NumberFormatId = 0U,
                FontId         = 0U,
                FillId         = 0U,
                BorderId       = 0U,
                FormatId       = 0U
            };

            cellFormats.Append(cellFormat2);

            CellStyles cellStyles = new CellStyles()
            {
                Count = 1U
            };
            CellStyle cellStyle = new CellStyle()
            {
                Name      = "Обычный",
                FormatId  = 0U,
                BuiltinId = 0U
            };
            cellStyles.Append(cellStyle);
            #endregion

            DifferentialFormats differentialFormats = new DifferentialFormats()
            {
                Count = 0U
            };
            TableStyles tableStyles = new TableStyles()
            {
                Count             = 0U,
                DefaultTableStyle = "TableStyleMedium2",
                DefaultPivotStyle = "PivotStyleLight16"
            };

            #region Stylesheet Extensions
            StylesheetExtensionList stylesheetExtensionList = new StylesheetExtensionList();

            StylesheetExtension stylesheetExtension1 = new StylesheetExtension()
            {
                Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
            };
            stylesheetExtension1.AddNamespaceDeclaration("x14",
                                                         "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
            X14.SlicerStyles slicerStyles = new X14.SlicerStyles()
            {
                DefaultSlicerStyle = "SlicerStyleLight1"
            };
            stylesheetExtension1.Append(slicerStyles);

            StylesheetExtension stylesheetExtension2 = new StylesheetExtension()
            {
                Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
            };
            stylesheetExtension2.AddNamespaceDeclaration("x15",
                                                         "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");

            OpenXmlUnknownElement unknownElement =
                OpenXmlUnknownElement.CreateOpenXmlUnknownElement(
                    "<x15:timelineStyles defaultTimelineStyle=\"TimeSlicerStyleLight1\" xmlns:x15=\"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main\" />");
            stylesheetExtension2.Append(unknownElement);

            stylesheetExtensionList.Append(stylesheetExtension1);
            stylesheetExtensionList.Append(stylesheetExtension2);
            #endregion

            stylesheet.Append(fonts);
            stylesheet.Append(fills);
            stylesheet.Append(borders);
            stylesheet.Append(cellStyleFormats);
            stylesheet.Append(cellFormats);
            stylesheet.Append(cellStyles);
            stylesheet.Append(differentialFormats);
            stylesheet.Append(tableStyles);
            stylesheet.Append(stylesheetExtensionList);

            workbookStylesPart.Stylesheet = stylesheet;
        }
Example #18
0
        // Creates an Numbering instance and adds its children.
        public static Numbering GenerateNumbering()
        {
            Numbering numbering1 = new Numbering()
            {
                MCAttributes = new MarkupCompatibilityAttributes()
                {
                    Ignorable = "w14 w15 w16se w16cid wp14"
                }
            };

            numbering1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            numbering1.AddNamespaceDeclaration("cx", "http://schemas.microsoft.com/office/drawing/2014/chartex");
            numbering1.AddNamespaceDeclaration("cx1", "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex");
            numbering1.AddNamespaceDeclaration("cx2", "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex");
            numbering1.AddNamespaceDeclaration("cx3", "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex");
            numbering1.AddNamespaceDeclaration("cx4", "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex");
            numbering1.AddNamespaceDeclaration("cx5", "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex");
            numbering1.AddNamespaceDeclaration("cx6", "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex");
            numbering1.AddNamespaceDeclaration("cx7", "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex");
            numbering1.AddNamespaceDeclaration("cx8", "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex");
            numbering1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            numbering1.AddNamespaceDeclaration("aink", "http://schemas.microsoft.com/office/drawing/2016/ink");
            numbering1.AddNamespaceDeclaration("am3d", "http://schemas.microsoft.com/office/drawing/2017/model3d");
            numbering1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            numbering1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            numbering1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            numbering1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            numbering1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            numbering1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            numbering1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            numbering1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            numbering1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            numbering1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml");
            numbering1.AddNamespaceDeclaration("w16cid", "http://schemas.microsoft.com/office/word/2016/wordml/cid");
            numbering1.AddNamespaceDeclaration("w16se", "http://schemas.microsoft.com/office/word/2015/wordml/symex");
            numbering1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            numbering1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            numbering1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            numbering1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            AbstractNum abstractNum1 = new AbstractNum()
            {
                AbstractNumberId = 0
            };

            abstractNum1.SetAttribute(new OpenXmlAttribute("w15", "restartNumberingAfterBreak", "http://schemas.microsoft.com/office/word/2012/wordml", "0"));
            Nsid nsid1 = new Nsid()
            {
                Val = "02791BC6"
            };
            MultiLevelType multiLevelType1 = new MultiLevelType()
            {
                Val = MultiLevelValues.Multilevel
            };
            TemplateCode templateCode1 = new TemplateCode()
            {
                Val = "565C7098"
            };

            Level level1 = new Level()
            {
                LevelIndex = 0
            };
            StartNumberingValue startNumberingValue1 = new StartNumberingValue()
            {
                Val = 1
            };
            NumberingFormat numberingFormat1 = new NumberingFormat()
            {
                Val = NumberFormatValues.Decimal
            };
            ParagraphStyleIdInLevel paragraphStyleIdInLevel1 = new ParagraphStyleIdInLevel()
            {
                Val = "Heading1"
            };
            LevelSuffix levelSuffix1 = new LevelSuffix()
            {
                Val = LevelSuffixValues.Nothing
            };
            LevelText levelText1 = new LevelText()
            {
                Val = "Article %1"
            };
            LevelJustification levelJustification1 = new LevelJustification()
            {
                Val = LevelJustificationValues.Left
            };

            PreviousParagraphProperties previousParagraphProperties1 = new PreviousParagraphProperties();
            Indentation indentation1 = new Indentation()
            {
                Left = "0", FirstLine = "0"
            };

            previousParagraphProperties1.Append(indentation1);

            NumberingSymbolRunProperties numberingSymbolRunProperties1 = new NumberingSymbolRunProperties();
            RunFonts runFonts1 = new RunFonts()
            {
                Hint = FontTypeHintValues.Default
            };

            numberingSymbolRunProperties1.Append(runFonts1);

            level1.Append(startNumberingValue1);
            level1.Append(numberingFormat1);
            level1.Append(paragraphStyleIdInLevel1);
            level1.Append(levelSuffix1);
            level1.Append(levelText1);
            level1.Append(levelJustification1);
            level1.Append(previousParagraphProperties1);
            level1.Append(numberingSymbolRunProperties1);

            Level level2 = new Level()
            {
                LevelIndex = 1
            };
            StartNumberingValue startNumberingValue2 = new StartNumberingValue()
            {
                Val = 1
            };
            NumberingFormat numberingFormat2 = new NumberingFormat()
            {
                Val = NumberFormatValues.Decimal
            };
            ParagraphStyleIdInLevel paragraphStyleIdInLevel2 = new ParagraphStyleIdInLevel()
            {
                Val = "Heading2"
            };
            LevelText levelText2 = new LevelText()
            {
                Val = "%1.%2"
            };
            LevelJustification levelJustification2 = new LevelJustification()
            {
                Val = LevelJustificationValues.Left
            };

            PreviousParagraphProperties previousParagraphProperties2 = new PreviousParagraphProperties();

            Tabs    tabs1    = new Tabs();
            TabStop tabStop1 = new TabStop()
            {
                Val = TabStopValues.Number, Position = 720
            };

            tabs1.Append(tabStop1);
            Indentation indentation2 = new Indentation()
            {
                Left = "0", FirstLine = "0"
            };

            previousParagraphProperties2.Append(tabs1);
            previousParagraphProperties2.Append(indentation2);

            NumberingSymbolRunProperties numberingSymbolRunProperties2 = new NumberingSymbolRunProperties();
            RunFonts runFonts2 = new RunFonts()
            {
                Hint = FontTypeHintValues.Default, ComplexScript = "Times New Roman"
            };
            Bold bold1 = new Bold()
            {
                Val = false
            };
            Italic italic1 = new Italic()
            {
                Val = false
            };
            ItalicComplexScript italicComplexScript1 = new ItalicComplexScript()
            {
                Val = false
            };
            Caps caps1 = new Caps()
            {
                Val = false
            };
            SmallCaps smallCaps1 = new SmallCaps()
            {
                Val = false
            };
            Strike strike1 = new Strike()
            {
                Val = false
            };
            DoubleStrike doubleStrike1 = new DoubleStrike()
            {
                Val = false
            };
            NoProof noProof1 = new NoProof()
            {
                Val = false
            };
            Vanish vanish1 = new Vanish()
            {
                Val = false
            };
            Color color1 = new Color()
            {
                Val = "000000"
            };
            Spacing spacing1 = new Spacing()
            {
                Val = 0
            };
            Kern kern1 = new Kern()
            {
                Val = 0U
            };
            Position position1 = new Position()
            {
                Val = "0"
            };
            Underline underline1 = new Underline()
            {
                Val = UnderlineValues.None
            };
            TextEffect textEffect1 = new TextEffect()
            {
                Val = TextEffectValues.None
            };
            VerticalTextAlignment verticalTextAlignment1 = new VerticalTextAlignment()
            {
                Val = VerticalPositionValues.Baseline
            };
            Emphasis emphasis1 = new Emphasis()
            {
                Val = EmphasisMarkValues.None
            };
            SpecVanish specVanish1 = new SpecVanish()
            {
                Val = false
            };

            OpenXmlUnknownElement openXmlUnknownElement1 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<w14:shadow w14:blurRad=\"0\" w14:dist=\"0\" w14:dir=\"0\" w14:sx=\"0\" w14:sy=\"0\" w14:kx=\"0\" w14:ky=\"0\" w14:algn=\"none\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\"><w14:srgbClr w14:val=\"000000\" /></w14:shadow>");

            OpenXmlUnknownElement openXmlUnknownElement2 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<w14:textOutline w14:w=\"0\" w14:cap=\"rnd\" w14:cmpd=\"sng\" w14:algn=\"ctr\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\"><w14:noFill /><w14:prstDash w14:val=\"solid\" /><w14:bevel /></w14:textOutline>");

            numberingSymbolRunProperties2.Append(runFonts2);
            numberingSymbolRunProperties2.Append(bold1);
            numberingSymbolRunProperties2.Append(italic1);
            numberingSymbolRunProperties2.Append(italicComplexScript1);
            numberingSymbolRunProperties2.Append(caps1);
            numberingSymbolRunProperties2.Append(smallCaps1);
            numberingSymbolRunProperties2.Append(strike1);
            numberingSymbolRunProperties2.Append(doubleStrike1);
            numberingSymbolRunProperties2.Append(noProof1);
            numberingSymbolRunProperties2.Append(vanish1);
            numberingSymbolRunProperties2.Append(color1);
            numberingSymbolRunProperties2.Append(spacing1);
            numberingSymbolRunProperties2.Append(kern1);
            numberingSymbolRunProperties2.Append(position1);
            numberingSymbolRunProperties2.Append(underline1);
            numberingSymbolRunProperties2.Append(textEffect1);
            numberingSymbolRunProperties2.Append(verticalTextAlignment1);
            numberingSymbolRunProperties2.Append(emphasis1);
            numberingSymbolRunProperties2.Append(specVanish1);
            numberingSymbolRunProperties2.Append(openXmlUnknownElement1);
            numberingSymbolRunProperties2.Append(openXmlUnknownElement2);

            level2.Append(startNumberingValue2);
            level2.Append(numberingFormat2);
            level2.Append(paragraphStyleIdInLevel2);
            level2.Append(levelText2);
            level2.Append(levelJustification2);
            level2.Append(previousParagraphProperties2);
            level2.Append(numberingSymbolRunProperties2);

            Level level3 = new Level()
            {
                LevelIndex = 2
            };
            StartNumberingValue startNumberingValue3 = new StartNumberingValue()
            {
                Val = 1
            };
            NumberingFormat numberingFormat3 = new NumberingFormat()
            {
                Val = NumberFormatValues.LowerLetter
            };
            ParagraphStyleIdInLevel paragraphStyleIdInLevel3 = new ParagraphStyleIdInLevel()
            {
                Val = "Heading3"
            };
            LevelText levelText3 = new LevelText()
            {
                Val = "(%3)"
            };
            LevelJustification levelJustification3 = new LevelJustification()
            {
                Val = LevelJustificationValues.Left
            };

            PreviousParagraphProperties previousParagraphProperties3 = new PreviousParagraphProperties();

            Tabs    tabs2    = new Tabs();
            TabStop tabStop2 = new TabStop()
            {
                Val = TabStopValues.Number, Position = 1800
            };

            tabs2.Append(tabStop2);
            Indentation indentation3 = new Indentation()
            {
                Left = "1800", Hanging = "720"
            };

            previousParagraphProperties3.Append(tabs2);
            previousParagraphProperties3.Append(indentation3);

            NumberingSymbolRunProperties numberingSymbolRunProperties3 = new NumberingSymbolRunProperties();
            RunFonts runFonts3 = new RunFonts()
            {
                Hint = FontTypeHintValues.Default
            };

            numberingSymbolRunProperties3.Append(runFonts3);

            level3.Append(startNumberingValue3);
            level3.Append(numberingFormat3);
            level3.Append(paragraphStyleIdInLevel3);
            level3.Append(levelText3);
            level3.Append(levelJustification3);
            level3.Append(previousParagraphProperties3);
            level3.Append(numberingSymbolRunProperties3);

            Level level4 = new Level()
            {
                LevelIndex = 3
            };
            StartNumberingValue startNumberingValue4 = new StartNumberingValue()
            {
                Val = 1
            };
            NumberingFormat numberingFormat4 = new NumberingFormat()
            {
                Val = NumberFormatValues.LowerRoman
            };
            ParagraphStyleIdInLevel paragraphStyleIdInLevel4 = new ParagraphStyleIdInLevel()
            {
                Val = "Heading4"
            };
            LevelText levelText4 = new LevelText()
            {
                Val = "(%4)"
            };
            LevelJustification levelJustification4 = new LevelJustification()
            {
                Val = LevelJustificationValues.Left
            };

            PreviousParagraphProperties previousParagraphProperties4 = new PreviousParagraphProperties();

            Tabs    tabs3    = new Tabs();
            TabStop tabStop3 = new TabStop()
            {
                Val = TabStopValues.Number, Position = 2160
            };

            tabs3.Append(tabStop3);
            Indentation indentation4 = new Indentation()
            {
                Left = "2160", Hanging = "720"
            };

            previousParagraphProperties4.Append(tabs3);
            previousParagraphProperties4.Append(indentation4);

            NumberingSymbolRunProperties numberingSymbolRunProperties4 = new NumberingSymbolRunProperties();
            RunFonts runFonts4 = new RunFonts()
            {
                Hint = FontTypeHintValues.Default
            };
            Bold bold2 = new Bold()
            {
                Val = false
            };
            Italic italic2 = new Italic()
            {
                Val = false
            };

            numberingSymbolRunProperties4.Append(runFonts4);
            numberingSymbolRunProperties4.Append(bold2);
            numberingSymbolRunProperties4.Append(italic2);

            level4.Append(startNumberingValue4);
            level4.Append(numberingFormat4);
            level4.Append(paragraphStyleIdInLevel4);
            level4.Append(levelText4);
            level4.Append(levelJustification4);
            level4.Append(previousParagraphProperties4);
            level4.Append(numberingSymbolRunProperties4);

            Level level5 = new Level()
            {
                LevelIndex = 4
            };
            StartNumberingValue startNumberingValue5 = new StartNumberingValue()
            {
                Val = 1
            };
            NumberingFormat numberingFormat5 = new NumberingFormat()
            {
                Val = NumberFormatValues.LowerLetter
            };
            ParagraphStyleIdInLevel paragraphStyleIdInLevel5 = new ParagraphStyleIdInLevel()
            {
                Val = "Heading5"
            };
            LevelText levelText5 = new LevelText()
            {
                Val = "%5)"
            };
            LevelJustification levelJustification5 = new LevelJustification()
            {
                Val = LevelJustificationValues.Left
            };

            PreviousParagraphProperties previousParagraphProperties5 = new PreviousParagraphProperties();

            Tabs    tabs4    = new Tabs();
            TabStop tabStop4 = new TabStop()
            {
                Val = TabStopValues.Number, Position = 2880
            };

            tabs4.Append(tabStop4);
            Indentation indentation5 = new Indentation()
            {
                Left = "2880", Hanging = "720"
            };

            previousParagraphProperties5.Append(tabs4);
            previousParagraphProperties5.Append(indentation5);

            NumberingSymbolRunProperties numberingSymbolRunProperties5 = new NumberingSymbolRunProperties();
            RunFonts runFonts5 = new RunFonts()
            {
                Hint = FontTypeHintValues.Default, Ascii = "Book Antiqua", HighAnsi = "Book Antiqua"
            };
            Bold bold3 = new Bold()
            {
                Val = false
            };
            Italic italic3 = new Italic()
            {
                Val = false
            };
            FontSize fontSize1 = new FontSize()
            {
                Val = "22"
            };

            numberingSymbolRunProperties5.Append(runFonts5);
            numberingSymbolRunProperties5.Append(bold3);
            numberingSymbolRunProperties5.Append(italic3);
            numberingSymbolRunProperties5.Append(fontSize1);

            level5.Append(startNumberingValue5);
            level5.Append(numberingFormat5);
            level5.Append(paragraphStyleIdInLevel5);
            level5.Append(levelText5);
            level5.Append(levelJustification5);
            level5.Append(previousParagraphProperties5);
            level5.Append(numberingSymbolRunProperties5);

            Level level6 = new Level()
            {
                LevelIndex = 5
            };
            StartNumberingValue startNumberingValue6 = new StartNumberingValue()
            {
                Val = 1
            };
            NumberingFormat numberingFormat6 = new NumberingFormat()
            {
                Val = NumberFormatValues.LowerRoman
            };
            ParagraphStyleIdInLevel paragraphStyleIdInLevel6 = new ParagraphStyleIdInLevel()
            {
                Val = "Heading6"
            };
            LevelText levelText6 = new LevelText()
            {
                Val = "(%6)"
            };
            LevelJustification levelJustification6 = new LevelJustification()
            {
                Val = LevelJustificationValues.Left
            };

            PreviousParagraphProperties previousParagraphProperties6 = new PreviousParagraphProperties();

            Tabs    tabs5    = new Tabs();
            TabStop tabStop5 = new TabStop()
            {
                Val = TabStopValues.Number, Position = 1440
            };

            tabs5.Append(tabStop5);
            Indentation indentation6 = new Indentation()
            {
                Left = "1440", Hanging = "720"
            };

            previousParagraphProperties6.Append(tabs5);
            previousParagraphProperties6.Append(indentation6);

            NumberingSymbolRunProperties numberingSymbolRunProperties6 = new NumberingSymbolRunProperties();
            RunFonts runFonts6 = new RunFonts()
            {
                Hint = FontTypeHintValues.Default, Ascii = "Book Antiqua", HighAnsi = "Book Antiqua"
            };
            Bold bold4 = new Bold()
            {
                Val = false
            };
            Italic italic4 = new Italic()
            {
                Val = false
            };
            FontSize fontSize2 = new FontSize()
            {
                Val = "22"
            };

            numberingSymbolRunProperties6.Append(runFonts6);
            numberingSymbolRunProperties6.Append(bold4);
            numberingSymbolRunProperties6.Append(italic4);
            numberingSymbolRunProperties6.Append(fontSize2);

            level6.Append(startNumberingValue6);
            level6.Append(numberingFormat6);
            level6.Append(paragraphStyleIdInLevel6);
            level6.Append(levelText6);
            level6.Append(levelJustification6);
            level6.Append(previousParagraphProperties6);
            level6.Append(numberingSymbolRunProperties6);

            Level level7 = new Level()
            {
                LevelIndex = 6
            };
            StartNumberingValue startNumberingValue7 = new StartNumberingValue()
            {
                Val = 1
            };
            NumberingFormat numberingFormat7 = new NumberingFormat()
            {
                Val = NumberFormatValues.Decimal
            };
            LevelText levelText7 = new LevelText()
            {
                Val = "%1.%2.%3.%4.%5.%6.%7."
            };
            LevelJustification levelJustification7 = new LevelJustification()
            {
                Val = LevelJustificationValues.Left
            };

            PreviousParagraphProperties previousParagraphProperties7 = new PreviousParagraphProperties();

            Tabs    tabs6    = new Tabs();
            TabStop tabStop6 = new TabStop()
            {
                Val = TabStopValues.Number, Position = 5400
            };

            tabs6.Append(tabStop6);
            Indentation indentation7 = new Indentation()
            {
                Left = "3240", Hanging = "1080"
            };

            previousParagraphProperties7.Append(tabs6);
            previousParagraphProperties7.Append(indentation7);

            NumberingSymbolRunProperties numberingSymbolRunProperties7 = new NumberingSymbolRunProperties();
            RunFonts runFonts7 = new RunFonts()
            {
                Hint = FontTypeHintValues.Default
            };

            numberingSymbolRunProperties7.Append(runFonts7);

            level7.Append(startNumberingValue7);
            level7.Append(numberingFormat7);
            level7.Append(levelText7);
            level7.Append(levelJustification7);
            level7.Append(previousParagraphProperties7);
            level7.Append(numberingSymbolRunProperties7);

            Level level8 = new Level()
            {
                LevelIndex = 7
            };
            StartNumberingValue startNumberingValue8 = new StartNumberingValue()
            {
                Val = 1
            };
            NumberingFormat numberingFormat8 = new NumberingFormat()
            {
                Val = NumberFormatValues.Decimal
            };
            LevelText levelText8 = new LevelText()
            {
                Val = "%1.%2.%3.%4.%5.%6.%7.%8."
            };
            LevelJustification levelJustification8 = new LevelJustification()
            {
                Val = LevelJustificationValues.Left
            };

            PreviousParagraphProperties previousParagraphProperties8 = new PreviousParagraphProperties();

            Tabs    tabs7    = new Tabs();
            TabStop tabStop7 = new TabStop()
            {
                Val = TabStopValues.Number, Position = 6120
            };

            tabs7.Append(tabStop7);
            Indentation indentation8 = new Indentation()
            {
                Left = "3744", Hanging = "1224"
            };

            previousParagraphProperties8.Append(tabs7);
            previousParagraphProperties8.Append(indentation8);

            NumberingSymbolRunProperties numberingSymbolRunProperties8 = new NumberingSymbolRunProperties();
            RunFonts runFonts8 = new RunFonts()
            {
                Hint = FontTypeHintValues.Default
            };

            numberingSymbolRunProperties8.Append(runFonts8);

            level8.Append(startNumberingValue8);
            level8.Append(numberingFormat8);
            level8.Append(levelText8);
            level8.Append(levelJustification8);
            level8.Append(previousParagraphProperties8);
            level8.Append(numberingSymbolRunProperties8);

            Level level9 = new Level()
            {
                LevelIndex = 8
            };
            StartNumberingValue startNumberingValue9 = new StartNumberingValue()
            {
                Val = 1
            };
            NumberingFormat numberingFormat9 = new NumberingFormat()
            {
                Val = NumberFormatValues.Decimal
            };
            LevelText levelText9 = new LevelText()
            {
                Val = "%1.%2.%3.%4.%5.%6.%7.%8.%9."
            };
            LevelJustification levelJustification9 = new LevelJustification()
            {
                Val = LevelJustificationValues.Left
            };

            PreviousParagraphProperties previousParagraphProperties9 = new PreviousParagraphProperties();

            Tabs    tabs8    = new Tabs();
            TabStop tabStop8 = new TabStop()
            {
                Val = TabStopValues.Number, Position = 6840
            };

            tabs8.Append(tabStop8);
            Indentation indentation9 = new Indentation()
            {
                Left = "4320", Hanging = "1440"
            };

            previousParagraphProperties9.Append(tabs8);
            previousParagraphProperties9.Append(indentation9);

            NumberingSymbolRunProperties numberingSymbolRunProperties9 = new NumberingSymbolRunProperties();
            RunFonts runFonts9 = new RunFonts()
            {
                Hint = FontTypeHintValues.Default
            };

            numberingSymbolRunProperties9.Append(runFonts9);

            level9.Append(startNumberingValue9);
            level9.Append(numberingFormat9);
            level9.Append(levelText9);
            level9.Append(levelJustification9);
            level9.Append(previousParagraphProperties9);
            level9.Append(numberingSymbolRunProperties9);

            abstractNum1.Append(nsid1);
            abstractNum1.Append(multiLevelType1);
            abstractNum1.Append(templateCode1);
            abstractNum1.Append(level1);
            abstractNum1.Append(level2);
            abstractNum1.Append(level3);
            abstractNum1.Append(level4);
            abstractNum1.Append(level5);
            abstractNum1.Append(level6);
            abstractNum1.Append(level7);
            abstractNum1.Append(level8);
            abstractNum1.Append(level9);

            NumberingInstance numberingInstance1 = new NumberingInstance()
            {
                NumberID = 1
            };
            AbstractNumId abstractNumId1 = new AbstractNumId()
            {
                Val = 0
            };

            LevelOverride levelOverride1 = new LevelOverride()
            {
                LevelIndex = 0
            };
            StartOverrideNumberingValue startOverrideNumberingValue1 = new StartOverrideNumberingValue()
            {
                Val = 2
            };

            levelOverride1.Append(startOverrideNumberingValue1);

            LevelOverride levelOverride2 = new LevelOverride()
            {
                LevelIndex = 1
            };
            StartOverrideNumberingValue startOverrideNumberingValue2 = new StartOverrideNumberingValue()
            {
                Val = 1
            };

            levelOverride2.Append(startOverrideNumberingValue2);

            LevelOverride levelOverride3 = new LevelOverride()
            {
                LevelIndex = 2
            };
            StartOverrideNumberingValue startOverrideNumberingValue3 = new StartOverrideNumberingValue()
            {
                Val = 1
            };

            levelOverride3.Append(startOverrideNumberingValue3);

            LevelOverride levelOverride4 = new LevelOverride()
            {
                LevelIndex = 3
            };
            StartOverrideNumberingValue startOverrideNumberingValue4 = new StartOverrideNumberingValue()
            {
                Val = 1
            };

            levelOverride4.Append(startOverrideNumberingValue4);

            LevelOverride levelOverride5 = new LevelOverride()
            {
                LevelIndex = 4
            };
            StartOverrideNumberingValue startOverrideNumberingValue5 = new StartOverrideNumberingValue()
            {
                Val = 1
            };

            levelOverride5.Append(startOverrideNumberingValue5);

            LevelOverride levelOverride6 = new LevelOverride()
            {
                LevelIndex = 5
            };
            StartOverrideNumberingValue startOverrideNumberingValue6 = new StartOverrideNumberingValue()
            {
                Val = 1
            };

            levelOverride6.Append(startOverrideNumberingValue6);

            LevelOverride levelOverride7 = new LevelOverride()
            {
                LevelIndex = 6
            };
            StartOverrideNumberingValue startOverrideNumberingValue7 = new StartOverrideNumberingValue()
            {
                Val = 1
            };

            levelOverride7.Append(startOverrideNumberingValue7);

            LevelOverride levelOverride8 = new LevelOverride()
            {
                LevelIndex = 7
            };
            StartOverrideNumberingValue startOverrideNumberingValue8 = new StartOverrideNumberingValue()
            {
                Val = 1
            };

            levelOverride8.Append(startOverrideNumberingValue8);

            LevelOverride levelOverride9 = new LevelOverride()
            {
                LevelIndex = 8
            };
            StartOverrideNumberingValue startOverrideNumberingValue9 = new StartOverrideNumberingValue()
            {
                Val = 1
            };

            levelOverride9.Append(startOverrideNumberingValue9);

            numberingInstance1.Append(abstractNumId1);
            numberingInstance1.Append(levelOverride1);
            numberingInstance1.Append(levelOverride2);
            numberingInstance1.Append(levelOverride3);
            numberingInstance1.Append(levelOverride4);
            numberingInstance1.Append(levelOverride5);
            numberingInstance1.Append(levelOverride6);
            numberingInstance1.Append(levelOverride7);
            numberingInstance1.Append(levelOverride8);
            numberingInstance1.Append(levelOverride9);

            NumberingInstance numberingInstance2 = new NumberingInstance()
            {
                NumberID = 2
            };
            AbstractNumId abstractNumId2 = new AbstractNumId()
            {
                Val = 0
            };

            numberingInstance2.Append(abstractNumId2);

            numbering1.Append(abstractNum1);
            numbering1.Append(numberingInstance1);
            numbering1.Append(numberingInstance2);
            return(numbering1);
        }
Example #19
0
        /// <summary>
        /// 样式
        /// </summary>
        /// <returns></returns>
        private void GenerateWorkbookStylesPart(WorkbookStylesPart workbookStylesPart)
        {
            Stylesheet styleSheet = new Stylesheet()
            {
                MCAttributes = new MarkupCompatibilityAttributes()
                {
                    Ignorable = "x14ac x16r2 xr"
                }
            };

            styleSheet.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            styleSheet.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac");
            styleSheet.AddNamespaceDeclaration("x16r2", "http://schemas.microsoft.com/office/spreadsheetml/2015/02/main");
            styleSheet.AddNamespaceDeclaration("xr", "http://schemas.microsoft.com/office/spreadsheetml/2014/revision");

            // 字体
            Fonts fonts = new Fonts(
                // 0 默认
                new Font(),
                // 1 表头
                new Font(
                    new Bold()
                    ));

            // 填充
            Fills fills = new Fills(
                new Fill(new PatternFill()
            {
                PatternType = PatternValues.None
            }),                                                                       // 0 默认
                new Fill(new PatternFill()
            {
                PatternType = PatternValues.Gray125
            })                                                                          // 0 默认
                );

            // 边框
            Borders borders = new Borders(
                // 0 默认,无边框
                new Border(
                    new LeftBorder(),
                    new RightBorder(),
                    new TopBorder(),
                    new BottomBorder(),
                    new DiagonalBorder()),
                new Border(       // 1 四周边框
                    new LeftBorder(new Color()
            {
                Auto = true
            })
            {
                Style = BorderStyleValues.Thin
            },
                    new RightBorder(new Color()
            {
                Auto = true
            })
            {
                Style = BorderStyleValues.Thin
            },
                    new TopBorder(new Color()
            {
                Auto = true
            })
            {
                Style = BorderStyleValues.Thin
            },
                    new BottomBorder(new Color()
            {
                Auto = true
            })
            {
                Style = BorderStyleValues.Thin
            },
                    new DiagonalBorder())
                );

            // 表格总体样式格式
            CellStyleFormats cellStyleFormats = new CellStyleFormats(
                new CellFormat()
            {
                NumberFormatId = 0, FontId = 0, FillId = 0, BorderId = 0
            }
                );

            // 表格格式
            CellFormats cellFormats = new CellFormats(
                new CellFormat()
            {
                NumberFormatId = 0, FontId = 0, FillId = 0, BorderId = 0, FormatId = 0
            },                                                                                                   // 默认
                new CellFormat()
            {
                NumberFormatId = 0, FontId = 1, FillId = 0, BorderId = 1, FormatId = 0, ApplyFont = true, ApplyBorder = true
            },                                                                                                                                         // 表头
                new CellFormat()
            {
                NumberFormatId = 0, FontId = 0, FillId = 0, BorderId = 1, FormatId = 0, ApplyBorder = true
            },                                                                                                                        // 文本内容
                new CellFormat()
            {
                NumberFormatId = 0, FontId = 0, FillId = 0, BorderId = 1, FormatId = 0, ApplyNumberFormat = true, ApplyBorder = true
            }                                                                                                                                                  // 数字内容
                );

            // 表格样式
            CellStyles cellStyles = new CellStyles(
                new CellStyle()
            {
                FormatId = 0, BuiltinId = 0
            }
                );

            StylesheetExtensionList stylesheetExtensionList = new StylesheetExtensionList();

            StylesheetExtension stylesheetExtensionX15 = new StylesheetExtension()
            {
                Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
            };

            stylesheetExtensionX15.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");

            OpenXmlUnknownElement openXmlUnknownElementX15 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<x15:timelineStyles defaultTimelineStyle=\"TimeSlicerStyleLight1\" xmlns:x15=\"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main\" />");

            stylesheetExtensionX15.Append(openXmlUnknownElementX15);
            stylesheetExtensionList.Append(stylesheetExtensionX15);

            styleSheet.Append(fonts);
            styleSheet.Append(fills);
            styleSheet.Append(borders);
            styleSheet.Append(cellStyleFormats);
            styleSheet.Append(cellFormats);
            styleSheet.Append(cellStyles);
            styleSheet.Append(stylesheetExtensionList);

            workbookStylesPart.Stylesheet = styleSheet;
        }
Example #20
0
        public static void GenerateHandoutMasterPart1Content(HandoutMasterPart handoutMasterPart1)
        {
            HandoutMaster handoutMaster1 = new HandoutMaster();

            handoutMaster1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
            handoutMaster1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            handoutMaster1.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main");

            CommonSlideData commonSlideData1 = new CommonSlideData();

            Background background1 = new Background();

            BackgroundStyleReference backgroundStyleReference1 = new BackgroundStyleReference()
            {
                Index = (UInt32Value)1001U
            };

            A.SchemeColor schemeColor10 = new A.SchemeColor()
            {
                Val = A.SchemeColorValues.Background1
            };

            backgroundStyleReference1.Append(schemeColor10);

            background1.Append(backgroundStyleReference1);

            ShapeTree shapeTree1 = new ShapeTree();

            NonVisualGroupShapeProperties nonVisualGroupShapeProperties1 = new NonVisualGroupShapeProperties();
            NonVisualDrawingProperties    nonVisualDrawingProperties1    = new NonVisualDrawingProperties()
            {
                Id = (UInt32Value)1U, Name = ""
            };
            NonVisualGroupShapeDrawingProperties  nonVisualGroupShapeDrawingProperties1  = new NonVisualGroupShapeDrawingProperties();
            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties1 = new ApplicationNonVisualDrawingProperties();

            nonVisualGroupShapeProperties1.Append(nonVisualDrawingProperties1);
            nonVisualGroupShapeProperties1.Append(nonVisualGroupShapeDrawingProperties1);
            nonVisualGroupShapeProperties1.Append(applicationNonVisualDrawingProperties1);

            GroupShapeProperties groupShapeProperties1 = new GroupShapeProperties();

            A.TransformGroup transformGroup1 = new A.TransformGroup();
            A.Offset         offset1         = new A.Offset()
            {
                X = 0L, Y = 0L
            };
            A.Extents extents1 = new A.Extents()
            {
                Cx = 0L, Cy = 0L
            };
            A.ChildOffset childOffset1 = new A.ChildOffset()
            {
                X = 0L, Y = 0L
            };
            A.ChildExtents childExtents1 = new A.ChildExtents()
            {
                Cx = 0L, Cy = 0L
            };

            transformGroup1.Append(offset1);
            transformGroup1.Append(extents1);
            transformGroup1.Append(childOffset1);
            transformGroup1.Append(childExtents1);

            groupShapeProperties1.Append(transformGroup1);

            Shape shape1 = new Shape();

            NonVisualShapeProperties nonVisualShapeProperties1 = new NonVisualShapeProperties();

            NonVisualDrawingProperties nonVisualDrawingProperties2 = new NonVisualDrawingProperties()
            {
                Id = (UInt32Value)2U, Name = "Header Placeholder 1"
            };

            A.NonVisualDrawingPropertiesExtensionList nonVisualDrawingPropertiesExtensionList1 = new A.NonVisualDrawingPropertiesExtensionList();

            A.NonVisualDrawingPropertiesExtension nonVisualDrawingPropertiesExtension1 = new A.NonVisualDrawingPropertiesExtension()
            {
                Uri = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"
            };

            OpenXmlUnknownElement openXmlUnknownElement1 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<a16:creationId xmlns:a16=\"http://schemas.microsoft.com/office/drawing/2014/main\" id=\"{6F844995-19E8-4464-BD76-40D129E09750}\" />");

            nonVisualDrawingPropertiesExtension1.Append(openXmlUnknownElement1);

            nonVisualDrawingPropertiesExtensionList1.Append(nonVisualDrawingPropertiesExtension1);

            nonVisualDrawingProperties2.Append(nonVisualDrawingPropertiesExtensionList1);

            NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties1 = new NonVisualShapeDrawingProperties();

            A.ShapeLocks shapeLocks1 = new A.ShapeLocks()
            {
                NoGrouping = true
            };

            nonVisualShapeDrawingProperties1.Append(shapeLocks1);

            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties2 = new ApplicationNonVisualDrawingProperties();
            PlaceholderShape placeholderShape1 = new PlaceholderShape()
            {
                Type = PlaceholderValues.Header, Size = PlaceholderSizeValues.Quarter
            };

            applicationNonVisualDrawingProperties2.Append(placeholderShape1);

            nonVisualShapeProperties1.Append(nonVisualDrawingProperties2);
            nonVisualShapeProperties1.Append(nonVisualShapeDrawingProperties1);
            nonVisualShapeProperties1.Append(applicationNonVisualDrawingProperties2);

            ShapeProperties shapeProperties1 = new ShapeProperties();

            A.Transform2D transform2D1 = new A.Transform2D();
            A.Offset      offset2      = new A.Offset()
            {
                X = 0L, Y = 1L
            };
            A.Extents extents2 = new A.Extents()
            {
                Cx = 2946400L, Cy = 495300L
            };

            transform2D1.Append(offset2);
            transform2D1.Append(extents2);

            A.PresetGeometry presetGeometry1 = new A.PresetGeometry()
            {
                Preset = A.ShapeTypeValues.Rectangle
            };
            A.AdjustValueList adjustValueList1 = new A.AdjustValueList();

            presetGeometry1.Append(adjustValueList1);

            shapeProperties1.Append(transform2D1);
            shapeProperties1.Append(presetGeometry1);

            TextBody textBody1 = new TextBody();

            A.BodyProperties bodyProperties1 = new A.BodyProperties()
            {
                Vertical = A.TextVerticalValues.Horizontal, LeftInset = 91440, TopInset = 45720, RightInset = 91440, BottomInset = 45720, RightToLeftColumns = false
            };

            A.ListStyle listStyle1 = new A.ListStyle();

            A.Level1ParagraphProperties level1ParagraphProperties2 = new A.Level1ParagraphProperties()
            {
                Alignment = A.TextAlignmentTypeValues.Left
            };
            A.DefaultRunProperties defaultRunProperties11 = new A.DefaultRunProperties()
            {
                FontSize = 1200
            };

            level1ParagraphProperties2.Append(defaultRunProperties11);

            listStyle1.Append(level1ParagraphProperties2);

            A.Paragraph paragraph1 = new A.Paragraph();
            A.EndParagraphRunProperties endParagraphRunProperties1 = new A.EndParagraphRunProperties()
            {
                Language = "en-GB"
            };

            paragraph1.Append(endParagraphRunProperties1);

            textBody1.Append(bodyProperties1);
            textBody1.Append(listStyle1);
            textBody1.Append(paragraph1);

            shape1.Append(nonVisualShapeProperties1);
            shape1.Append(shapeProperties1);
            shape1.Append(textBody1);

            Shape shape2 = new Shape();

            NonVisualShapeProperties nonVisualShapeProperties2 = new NonVisualShapeProperties();

            NonVisualDrawingProperties nonVisualDrawingProperties3 = new NonVisualDrawingProperties()
            {
                Id = (UInt32Value)3U, Name = "Date Placeholder 2"
            };

            A.NonVisualDrawingPropertiesExtensionList nonVisualDrawingPropertiesExtensionList2 = new A.NonVisualDrawingPropertiesExtensionList();

            A.NonVisualDrawingPropertiesExtension nonVisualDrawingPropertiesExtension2 = new A.NonVisualDrawingPropertiesExtension()
            {
                Uri = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"
            };

            OpenXmlUnknownElement openXmlUnknownElement2 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<a16:creationId xmlns:a16=\"http://schemas.microsoft.com/office/drawing/2014/main\" id=\"{DAB3772C-5103-431C-B581-8408B3A89922}\" />");

            nonVisualDrawingPropertiesExtension2.Append(openXmlUnknownElement2);

            nonVisualDrawingPropertiesExtensionList2.Append(nonVisualDrawingPropertiesExtension2);

            nonVisualDrawingProperties3.Append(nonVisualDrawingPropertiesExtensionList2);

            NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties2 = new NonVisualShapeDrawingProperties();

            A.ShapeLocks shapeLocks2 = new A.ShapeLocks()
            {
                NoGrouping = true
            };

            nonVisualShapeDrawingProperties2.Append(shapeLocks2);

            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties3 = new ApplicationNonVisualDrawingProperties();
            PlaceholderShape placeholderShape2 = new PlaceholderShape()
            {
                Type = PlaceholderValues.DateAndTime, Size = PlaceholderSizeValues.Quarter, Index = (UInt32Value)1U
            };

            applicationNonVisualDrawingProperties3.Append(placeholderShape2);

            nonVisualShapeProperties2.Append(nonVisualDrawingProperties3);
            nonVisualShapeProperties2.Append(nonVisualShapeDrawingProperties2);
            nonVisualShapeProperties2.Append(applicationNonVisualDrawingProperties3);

            ShapeProperties shapeProperties2 = new ShapeProperties();

            A.Transform2D transform2D2 = new A.Transform2D();
            A.Offset      offset3      = new A.Offset()
            {
                X = 3849688L, Y = 1L
            };
            A.Extents extents3 = new A.Extents()
            {
                Cx = 2946400L, Cy = 495300L
            };

            transform2D2.Append(offset3);
            transform2D2.Append(extents3);

            A.PresetGeometry presetGeometry2 = new A.PresetGeometry()
            {
                Preset = A.ShapeTypeValues.Rectangle
            };
            A.AdjustValueList adjustValueList2 = new A.AdjustValueList();

            presetGeometry2.Append(adjustValueList2);

            shapeProperties2.Append(transform2D2);
            shapeProperties2.Append(presetGeometry2);

            TextBody textBody2 = new TextBody();

            A.BodyProperties bodyProperties2 = new A.BodyProperties()
            {
                Vertical = A.TextVerticalValues.Horizontal, LeftInset = 91440, TopInset = 45720, RightInset = 91440, BottomInset = 45720, RightToLeftColumns = false
            };

            A.ListStyle listStyle2 = new A.ListStyle();

            A.Level1ParagraphProperties level1ParagraphProperties3 = new A.Level1ParagraphProperties()
            {
                Alignment = A.TextAlignmentTypeValues.Right
            };
            A.DefaultRunProperties defaultRunProperties12 = new A.DefaultRunProperties()
            {
                FontSize = 1200
            };

            level1ParagraphProperties3.Append(defaultRunProperties12);

            listStyle2.Append(level1ParagraphProperties3);

            A.Paragraph paragraph2 = new A.Paragraph();

            A.Field field1 = new A.Field()
            {
                Id = "{2193C790-BB76-448B-9064-927E80682452}", Type = "datetimeFigureOut"
            };

            A.RunProperties runProperties1 = new A.RunProperties()
            {
                Language = "en-GB"
            };
            runProperties1.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0"));
            A.Text text1 = new A.Text();
            text1.Text = $"{DateTime.Now.Day}.{DateTime.Now.Month}.{DateTime.Now.Year}";

            field1.Append(runProperties1);
            field1.Append(text1);
            A.EndParagraphRunProperties endParagraphRunProperties2 = new A.EndParagraphRunProperties()
            {
                Language = "en-GB"
            };

            paragraph2.Append(field1);
            paragraph2.Append(endParagraphRunProperties2);

            textBody2.Append(bodyProperties2);
            textBody2.Append(listStyle2);
            textBody2.Append(paragraph2);

            shape2.Append(nonVisualShapeProperties2);
            shape2.Append(shapeProperties2);
            shape2.Append(textBody2);

            Shape shape3 = new Shape();

            NonVisualShapeProperties nonVisualShapeProperties3 = new NonVisualShapeProperties();

            NonVisualDrawingProperties nonVisualDrawingProperties4 = new NonVisualDrawingProperties()
            {
                Id = (UInt32Value)4U, Name = "Footer Placeholder 3"
            };

            A.NonVisualDrawingPropertiesExtensionList nonVisualDrawingPropertiesExtensionList3 = new A.NonVisualDrawingPropertiesExtensionList();

            A.NonVisualDrawingPropertiesExtension nonVisualDrawingPropertiesExtension3 = new A.NonVisualDrawingPropertiesExtension()
            {
                Uri = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"
            };

            OpenXmlUnknownElement openXmlUnknownElement3 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<a16:creationId xmlns:a16=\"http://schemas.microsoft.com/office/drawing/2014/main\" id=\"{8F527AE1-483F-4AAE-B350-632A657A43A5}\" />");

            nonVisualDrawingPropertiesExtension3.Append(openXmlUnknownElement3);

            nonVisualDrawingPropertiesExtensionList3.Append(nonVisualDrawingPropertiesExtension3);

            nonVisualDrawingProperties4.Append(nonVisualDrawingPropertiesExtensionList3);

            NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties3 = new NonVisualShapeDrawingProperties();

            A.ShapeLocks shapeLocks3 = new A.ShapeLocks()
            {
                NoGrouping = true
            };

            nonVisualShapeDrawingProperties3.Append(shapeLocks3);

            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties4 = new ApplicationNonVisualDrawingProperties();
            PlaceholderShape placeholderShape3 = new PlaceholderShape()
            {
                Type = PlaceholderValues.Footer, Size = PlaceholderSizeValues.Quarter, Index = (UInt32Value)2U
            };

            applicationNonVisualDrawingProperties4.Append(placeholderShape3);

            nonVisualShapeProperties3.Append(nonVisualDrawingProperties4);
            nonVisualShapeProperties3.Append(nonVisualShapeDrawingProperties3);
            nonVisualShapeProperties3.Append(applicationNonVisualDrawingProperties4);

            ShapeProperties shapeProperties3 = new ShapeProperties();

            A.Transform2D transform2D3 = new A.Transform2D();
            A.Offset      offset4      = new A.Offset()
            {
                X = 0L, Y = 9378950L
            };
            A.Extents extents4 = new A.Extents()
            {
                Cx = 2946400L, Cy = 495300L
            };

            transform2D3.Append(offset4);
            transform2D3.Append(extents4);

            A.PresetGeometry presetGeometry3 = new A.PresetGeometry()
            {
                Preset = A.ShapeTypeValues.Rectangle
            };
            A.AdjustValueList adjustValueList3 = new A.AdjustValueList();

            presetGeometry3.Append(adjustValueList3);

            shapeProperties3.Append(transform2D3);
            shapeProperties3.Append(presetGeometry3);

            TextBody textBody3 = new TextBody();

            A.BodyProperties bodyProperties3 = new A.BodyProperties()
            {
                Vertical = A.TextVerticalValues.Horizontal, LeftInset = 91440, TopInset = 45720, RightInset = 91440, BottomInset = 45720, RightToLeftColumns = false, Anchor = A.TextAnchoringTypeValues.Bottom
            };

            A.ListStyle listStyle3 = new A.ListStyle();

            A.Level1ParagraphProperties level1ParagraphProperties4 = new A.Level1ParagraphProperties()
            {
                Alignment = A.TextAlignmentTypeValues.Left
            };
            A.DefaultRunProperties defaultRunProperties13 = new A.DefaultRunProperties()
            {
                FontSize = 1200
            };

            level1ParagraphProperties4.Append(defaultRunProperties13);

            listStyle3.Append(level1ParagraphProperties4);

            A.Paragraph paragraph3 = new A.Paragraph();
            A.EndParagraphRunProperties endParagraphRunProperties3 = new A.EndParagraphRunProperties()
            {
                Language = "en-GB"
            };

            paragraph3.Append(endParagraphRunProperties3);

            textBody3.Append(bodyProperties3);
            textBody3.Append(listStyle3);
            textBody3.Append(paragraph3);

            shape3.Append(nonVisualShapeProperties3);
            shape3.Append(shapeProperties3);
            shape3.Append(textBody3);

            Shape shape4 = new Shape();

            NonVisualShapeProperties nonVisualShapeProperties4 = new NonVisualShapeProperties();

            NonVisualDrawingProperties nonVisualDrawingProperties5 = new NonVisualDrawingProperties()
            {
                Id = (UInt32Value)5U, Name = "Slide Number Placeholder 4"
            };

            A.NonVisualDrawingPropertiesExtensionList nonVisualDrawingPropertiesExtensionList4 = new A.NonVisualDrawingPropertiesExtensionList();

            A.NonVisualDrawingPropertiesExtension nonVisualDrawingPropertiesExtension4 = new A.NonVisualDrawingPropertiesExtension()
            {
                Uri = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"
            };

            OpenXmlUnknownElement openXmlUnknownElement4 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<a16:creationId xmlns:a16=\"http://schemas.microsoft.com/office/drawing/2014/main\" id=\"{B30BB125-185A-4706-BD59-793EEE2C8B8C}\" />");

            nonVisualDrawingPropertiesExtension4.Append(openXmlUnknownElement4);

            nonVisualDrawingPropertiesExtensionList4.Append(nonVisualDrawingPropertiesExtension4);

            nonVisualDrawingProperties5.Append(nonVisualDrawingPropertiesExtensionList4);

            NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties4 = new NonVisualShapeDrawingProperties();

            A.ShapeLocks shapeLocks4 = new A.ShapeLocks()
            {
                NoGrouping = true
            };

            nonVisualShapeDrawingProperties4.Append(shapeLocks4);

            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties5 = new ApplicationNonVisualDrawingProperties();
            PlaceholderShape placeholderShape4 = new PlaceholderShape()
            {
                Type = PlaceholderValues.SlideNumber, Size = PlaceholderSizeValues.Quarter, Index = (UInt32Value)3U
            };

            applicationNonVisualDrawingProperties5.Append(placeholderShape4);

            nonVisualShapeProperties4.Append(nonVisualDrawingProperties5);
            nonVisualShapeProperties4.Append(nonVisualShapeDrawingProperties4);
            nonVisualShapeProperties4.Append(applicationNonVisualDrawingProperties5);

            ShapeProperties shapeProperties4 = new ShapeProperties();

            A.Transform2D transform2D4 = new A.Transform2D();
            A.Offset      offset5      = new A.Offset()
            {
                X = 3849688L, Y = 9378950L
            };
            A.Extents extents5 = new A.Extents()
            {
                Cx = 2946400L, Cy = 495300L
            };

            transform2D4.Append(offset5);
            transform2D4.Append(extents5);

            A.PresetGeometry presetGeometry4 = new A.PresetGeometry()
            {
                Preset = A.ShapeTypeValues.Rectangle
            };
            A.AdjustValueList adjustValueList4 = new A.AdjustValueList();

            presetGeometry4.Append(adjustValueList4);

            shapeProperties4.Append(transform2D4);
            shapeProperties4.Append(presetGeometry4);

            TextBody textBody4 = new TextBody();

            A.BodyProperties bodyProperties4 = new A.BodyProperties()
            {
                Vertical = A.TextVerticalValues.Horizontal, LeftInset = 91440, TopInset = 45720, RightInset = 91440, BottomInset = 45720, RightToLeftColumns = false, Anchor = A.TextAnchoringTypeValues.Bottom
            };

            A.ListStyle listStyle4 = new A.ListStyle();

            A.Level1ParagraphProperties level1ParagraphProperties5 = new A.Level1ParagraphProperties()
            {
                Alignment = A.TextAlignmentTypeValues.Right
            };
            A.DefaultRunProperties defaultRunProperties14 = new A.DefaultRunProperties()
            {
                FontSize = 1200
            };

            level1ParagraphProperties5.Append(defaultRunProperties14);

            listStyle4.Append(level1ParagraphProperties5);

            A.Paragraph paragraph4 = new A.Paragraph();

            A.Field field2 = new A.Field()
            {
                Id = "{409988AC-3923-45CB-9D2C-0BEBFEE96CD9}", Type = "slidenum"
            };

            A.RunProperties runProperties2 = new A.RunProperties()
            {
                Language = "en-GB"
            };
            runProperties2.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0"));
            A.Text text2 = new A.Text();
            text2.Text = "‹#›";

            field2.Append(runProperties2);
            field2.Append(text2);
            A.EndParagraphRunProperties endParagraphRunProperties4 = new A.EndParagraphRunProperties()
            {
                Language = "en-GB"
            };

            paragraph4.Append(field2);
            paragraph4.Append(endParagraphRunProperties4);

            textBody4.Append(bodyProperties4);
            textBody4.Append(listStyle4);
            textBody4.Append(paragraph4);

            shape4.Append(nonVisualShapeProperties4);
            shape4.Append(shapeProperties4);
            shape4.Append(textBody4);

            shapeTree1.Append(nonVisualGroupShapeProperties1);
            shapeTree1.Append(groupShapeProperties1);
            shapeTree1.Append(shape1);
            shapeTree1.Append(shape2);
            shapeTree1.Append(shape3);
            shapeTree1.Append(shape4);

            CommonSlideDataExtensionList commonSlideDataExtensionList1 = new CommonSlideDataExtensionList();

            CommonSlideDataExtension commonSlideDataExtension1 = new CommonSlideDataExtension()
            {
                Uri = "{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}"
            };

            P14.CreationId creationId1 = new P14.CreationId()
            {
                Val = (UInt32Value)1485009629U
            };
            creationId1.AddNamespaceDeclaration("p14", "http://schemas.microsoft.com/office/powerpoint/2010/main");

            commonSlideDataExtension1.Append(creationId1);

            commonSlideDataExtensionList1.Append(commonSlideDataExtension1);

            commonSlideData1.Append(background1);
            commonSlideData1.Append(shapeTree1);
            commonSlideData1.Append(commonSlideDataExtensionList1);
            ColorMap colorMap1 = new ColorMap()
            {
                Background1 = A.ColorSchemeIndexValues.Light1, Text1 = A.ColorSchemeIndexValues.Dark1, Background2 = A.ColorSchemeIndexValues.Light2, Text2 = A.ColorSchemeIndexValues.Dark2, Accent1 = A.ColorSchemeIndexValues.Accent1, Accent2 = A.ColorSchemeIndexValues.Accent2, Accent3 = A.ColorSchemeIndexValues.Accent3, Accent4 = A.ColorSchemeIndexValues.Accent4, Accent5 = A.ColorSchemeIndexValues.Accent5, Accent6 = A.ColorSchemeIndexValues.Accent6, Hyperlink = A.ColorSchemeIndexValues.Hyperlink, FollowedHyperlink = A.ColorSchemeIndexValues.FollowedHyperlink
            };

            handoutMaster1.Append(commonSlideData1);
            handoutMaster1.Append(colorMap1);

            handoutMasterPart1.HandoutMaster = handoutMaster1;
        }
Example #21
0
        // Generates content of drawingsPart1.
        //private void GenerateDrawingsPartContent(DrawingsPart drawingsPart, Chart chart)
        //{
        //	var worksheetDrawing = new Xdr.WorksheetDrawing();
        //	worksheetDrawing.AddNamespaceDeclaration("xdr", "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
        //	worksheetDrawing.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");

        //	var twoCellAnchor = new Xdr.TwoCellAnchor();

        //	var fromMarker = new Xdr.FromMarker();
        //	var columnIdFrom = new Xdr.ColumnId();
        //	columnIdFrom.Text = chart.ColumnFrom.ToString();
        //	Xdr.ColumnOffset columnOffsetFrom = new Xdr.ColumnOffset();
        //	columnOffsetFrom.Text = "11908";
        //	var rowIdFrom = new Xdr.RowId();
        //	rowIdFrom.Text = chart.RowFrom.ToString();
        //	Xdr.RowOffset rowOffsetFrom = new Xdr.RowOffset();
        //	rowOffsetFrom.Text = "9523";

        //	fromMarker.Append(columnIdFrom);
        //	fromMarker.Append(columnOffsetFrom);
        //	fromMarker.Append(rowIdFrom);
        //	fromMarker.Append(rowOffsetFrom);

        //	var toMarker = new Xdr.ToMarker();
        //	var columnIdTo = new Xdr.ColumnId();
        //	columnIdTo.Text = chart.ColumnTo.ToString();
        //	Xdr.ColumnOffset columnOffsetTo = new Xdr.ColumnOffset();
        //	columnOffsetTo.Text = "250032";
        //	var rowIdTo = new Xdr.RowId();
        //	rowIdTo.Text = chart.RowTo.ToString();
        //	Xdr.RowOffset rowOffsetTo = new Xdr.RowOffset();
        //	rowOffsetTo.Text = "29764";

        //	toMarker.Append(columnIdTo);
        //	toMarker.Append(columnOffsetTo);
        //	toMarker.Append(rowIdTo);
        //	toMarker.Append(rowOffsetTo);

        //	var graphicFrame = new Xdr.GraphicFrame() { Macro = "" };

        //	var nonVisualGraphicFrameProperties = new Xdr.NonVisualGraphicFrameProperties();
        //	var nonVisualDrawingProperties = new Xdr.NonVisualDrawingProperties() { Id = (UInt32Value)2U, Name = chart.TableKey };

        //	var nonVisualGraphicFrameDrawingProperties = new Xdr.NonVisualGraphicFrameDrawingProperties();
        //	var graphicFrameLocks = new A.GraphicFrameLocks();

        //	nonVisualGraphicFrameDrawingProperties.Append(graphicFrameLocks);

        //	nonVisualGraphicFrameProperties.Append(nonVisualDrawingProperties);
        //	nonVisualGraphicFrameProperties.Append(nonVisualGraphicFrameDrawingProperties);

        //	var transform = new Xdr.Transform();
        //	var offset = new A.Offset() { X = 0L, Y = 0L };
        //	var extents = new A.Extents() { Cx = 0L, Cy = 0L };

        //	transform.Append(offset);
        //	transform.Append(extents);

        //	var graphic = new A.Graphic();

        //	var graphicData = new A.GraphicData() { Uri = "http://schemas.openxmlformats.org/drawingml/2006/chart" };

        //	var chartReference = new C.ChartReference() { Id = "rId1" };
        //	chartReference.AddNamespaceDeclaration("c", "http://schemas.openxmlformats.org/drawingml/2006/chart");
        //	chartReference.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");

        //	graphicData.Append(chartReference);

        //	graphic.Append(graphicData);

        //	graphicFrame.Append(nonVisualGraphicFrameProperties);
        //	graphicFrame.Append(transform);
        //	graphicFrame.Append(graphic);
        //	var clientData = new Xdr.ClientData();

        //	twoCellAnchor.Append(fromMarker);
        //	twoCellAnchor.Append(toMarker);
        //	twoCellAnchor.Append(graphicFrame);
        //	twoCellAnchor.Append(clientData);

        //	worksheetDrawing.Append(twoCellAnchor);

        //	drawingsPart.WorksheetDrawing = worksheetDrawing;
        //}

        //// Generates content of chartPart1.
        //private void GenerateChartPartContent(ChartPart chartPart, Chart chart)
        //{
        //	var chartSpace = new C.ChartSpace();
        //	chartSpace.AddNamespaceDeclaration("c", "http://schemas.openxmlformats.org/drawingml/2006/chart");
        //	chartSpace.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
        //	chartSpace.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
        //	var editingLanguage = new C.EditingLanguage() { Val = "en-US" };
        //	var style = new C.Style() { Val = 10 };

        //	var _chart = new C.Chart();

        //	var title = new C.Title();

        //	var chartText = new C.ChartText();

        //	var richText = new C.RichText();
        //	var bodyProperties = new A.BodyProperties();
        //	var listStyle = new A.ListStyle();

        //	var paragraph = new A.Paragraph();

        //	var paragraphProperties = new A.ParagraphProperties();
        //	var defaultRunProperties = new A.DefaultRunProperties();

        //	paragraphProperties.Append(defaultRunProperties);

        //	var run = new A.Run();
        //	var runProperties = new A.RunProperties() { Language = "en-US", FontSize = 800 };
        //	var text = new A.Text();
        //	text.Text = chart.Title;

        //	run.Append(runProperties);
        //	run.Append(text);

        //	//A.Run run2 = new A.Run();
        //	//A.RunProperties runProperties2 = new A.RunProperties() { Language = "en-US", FontSize = 800, Baseline = 0 };
        //	//A.Text text2 = new A.Text();
        //	//text2.Text = title;

        //	//run2.Append(runProperties2);
        //	//run2.Append(text2);
        //	var endParagraphRunProperties = new A.EndParagraphRunProperties() { Language = "en-US", FontSize = 800 };

        //	paragraph.Append(paragraphProperties);
        //	paragraph.Append(run);
        //	//paragraph1.Append(run2);
        //	paragraph.Append(endParagraphRunProperties);

        //	richText.Append(bodyProperties);
        //	richText.Append(listStyle);
        //	richText.Append(paragraph);

        //	chartText.Append(richText);

        //	var layout1 = new C.Layout();

        //	var manualLayout1 = new C.ManualLayout();
        //	var leftMode1 = new C.LeftMode() { Val = C.LayoutModeValues.Edge };
        //	var topMode1 = new C.TopMode() { Val = C.LayoutModeValues.Edge };
        //	var left1 = new C.Left() { Val = 0.14936699324798144D };
        //	var top1 = new C.Top() { Val = 7.5867300613079197E-2D };


        //	manualLayout1.Append(leftMode1);
        //	manualLayout1.Append(topMode1);
        //	manualLayout1.Append(left1);
        //	manualLayout1.Append(top1);

        //	layout1.Append(manualLayout1);

        //	title.Append(chartText);
        //	title.Append(layout1);

        //	var plotArea = new C.PlotArea();

        //	var layout2 = new C.Layout();

        //	var manualLayout2 = new C.ManualLayout();
        //	var layoutTarget2 = new C.LayoutTarget() { Val = C.LayoutTargetValues.Inner };
        //	var leftMode2 = new C.LeftMode() { Val = C.LayoutModeValues.Edge };
        //	var topMode2 = new C.TopMode() { Val = C.LayoutModeValues.Edge };
        //	var left2 = new C.Left() { Val = 0.10245464404093282D };
        //	var top2 = new C.Top() { Val = 4.7416814491091287E-2D };
        //	var width2 = new C.Width() { Val = 0.88919609910728359D };

        //	// chart height inside word drawing part
        //	//C.Height height1 = new C.Height() { Val = 0.81899924741893582D }; // original generated value
        //	var height2 = new C.Height() { Val = 0.86 };

        //	manualLayout2.Append(layoutTarget2);
        //	manualLayout2.Append(leftMode2);
        //	manualLayout2.Append(topMode2);
        //	manualLayout2.Append(left2);
        //	manualLayout2.Append(top2);
        //	manualLayout2.Append(width2);
        //	manualLayout2.Append(height2);

        //	layout2.Append(manualLayout2);

        //	var areaChart = new C.AreaChart();
        //	var grouping = new C.Grouping() { Val = C.GroupingValues.Standard };

        //	var areaChartSeries = new C.AreaChartSeries();
        //	var index = new C.Index() { Val = (UInt32Value)0U };
        //	var order = new C.Order() { Val = (UInt32Value)0U };

        //	var seriesText = new C.SeriesText();

        //	var stringReference = new C.StringReference();
        //	var formula1 = new C.Formula();
        //	formula1.Text = chart.AxisX;

        //	var stringCache = new C.StringCache();
        //	var pointCount1 = new C.PointCount() { Val = (UInt32Value)1U };

        //	var stringPoint = new C.StringPoint() { Index = (UInt32Value)0U };
        //	var numericValue = new C.NumericValue();
        //	numericValue.Text = chart.LegendTitle;

        //	stringPoint.Append(numericValue);

        //	stringCache.Append(pointCount1);
        //	stringCache.Append(stringPoint);

        //	stringReference.Append(formula1);
        //	stringReference.Append(stringCache);

        //	seriesText.Append(stringReference);

        //	var values = new C.Values();

        //	var numberReference = new C.NumberReference();
        //	var formula2 = new C.Formula();
        //	formula2.Text = chart.AxisY;

        //	C.NumberingCache numberingCache = new C.NumberingCache();
        //	C.FormatCode formatCode = new C.FormatCode();
        //	formatCode.Text = "0.00%";

        //	/* years */
        //	C.PointCount pointCount2 = new C.PointCount() { Val = UInt32Value.FromUInt32((uint)chart.Labels.Count) };

        //	numberingCache.Append(formatCode);
        //	numberingCache.Append(pointCount2);

        //	for (int i = 0; i < chart.Labels.Count; i++)
        //	{
        //		C.NumericPoint numericPoint = new C.NumericPoint() { Index = UInt32Value.FromUInt32((uint)i) };
        //		C.NumericValue _numericValue = new C.NumericValue();
        //		numericValue.Text = string.Format("{0}E-2", chart.Labels[i]);
        //		numericPoint.Append(_numericValue);
        //		numberingCache.Append(numericPoint);
        //	}

        //	numberReference.Append(formula2);
        //	numberReference.Append(numberingCache);

        //	values.Append(numberReference);

        //	areaChartSeries.Append(index);
        //	areaChartSeries.Append(order);
        //	areaChartSeries.Append(seriesText);
        //	areaChartSeries.Append(values);
        //	var axisId1 = new C.AxisId() { Val = (UInt32Value)78173696U };
        //	var axisId2 = new C.AxisId() { Val = (UInt32Value)78175232U };

        //	areaChart.Append(grouping);
        //	areaChart.Append(areaChartSeries);
        //	areaChart.Append(axisId1);
        //	areaChart.Append(axisId2);

        //	var categoryAxis1 = new C.CategoryAxis();
        //	var axisId3 = new C.AxisId() { Val = (UInt32Value)78173696U };

        //	var scaling1 = new C.Scaling();
        //	var orientation1 = new C.Orientation() { Val = C.OrientationValues.MinMax };

        //	scaling1.Append(orientation1);
        //	var axisPosition1 = new C.AxisPosition() { Val = C.AxisPositionValues.Bottom };
        //	var majorTickMark1 = new C.MajorTickMark() { Val = C.TickMarkValues.None };
        //	var tickLabelPosition1 = new C.TickLabelPosition() { Val = C.TickLabelPositionValues.NextTo };
        //	var crossingAxis1 = new C.CrossingAxis() { Val = (UInt32Value)78175232U };
        //	var crosses1 = new C.Crosses() { Val = C.CrossesValues.AutoZero };
        //	var autoLabeled1 = new C.AutoLabeled() { Val = true };
        //	var labelAlignment1 = new C.LabelAlignment() { Val = C.LabelAlignmentValues.Center };
        //	var labelOffset1 = new C.LabelOffset() { Val = (UInt16Value)100U };

        //	categoryAxis1.Append(axisId3);
        //	categoryAxis1.Append(scaling1);
        //	categoryAxis1.Append(axisPosition1);
        //	categoryAxis1.Append(majorTickMark1);
        //	categoryAxis1.Append(tickLabelPosition1);
        //	categoryAxis1.Append(crossingAxis1);
        //	categoryAxis1.Append(crosses1);
        //	categoryAxis1.Append(autoLabeled1);
        //	categoryAxis1.Append(labelAlignment1);
        //	categoryAxis1.Append(labelOffset1);

        //	var valueAxis1 = new C.ValueAxis();
        //	var axisId4 = new C.AxisId() { Val = (UInt32Value)78175232U };

        //	var scaling2 = new C.Scaling();
        //	var orientation2 = new C.Orientation() { Val = C.OrientationValues.MinMax };

        //	scaling2.Append(orientation2);
        //	var axisPosition2 = new C.AxisPosition() { Val = C.AxisPositionValues.Left };
        //	var majorGridlines1 = new C.MajorGridlines();
        //	var numberingFormat1 = new C.NumberingFormat() { FormatCode = "0.00%", SourceLinked = true };
        //	var majorTickMark2 = new C.MajorTickMark() { Val = C.TickMarkValues.None };
        //	var tickLabelPosition2 = new C.TickLabelPosition() { Val = C.TickLabelPositionValues.NextTo };
        //	var crossingAxis2 = new C.CrossingAxis() { Val = (UInt32Value)78173696U };
        //	var crosses2 = new C.Crosses() { Val = C.CrossesValues.AutoZero };
        //	var crossBetween1 = new C.CrossBetween() { Val = C.CrossBetweenValues.MidpointCategory };

        //	valueAxis1.Append(axisId4);
        //	valueAxis1.Append(scaling2);
        //	valueAxis1.Append(axisPosition2);
        //	valueAxis1.Append(majorGridlines1);
        //	valueAxis1.Append(numberingFormat1);
        //	valueAxis1.Append(majorTickMark2);
        //	valueAxis1.Append(tickLabelPosition2);
        //	valueAxis1.Append(crossingAxis2);
        //	valueAxis1.Append(crosses2);
        //	valueAxis1.Append(crossBetween1);

        //	var dataTable1 = new C.DataTable();
        //	var showHorizontalBorder1 = new C.ShowHorizontalBorder() { Val = true };
        //	var showVerticalBorder1 = new C.ShowVerticalBorder() { Val = true };
        //	var showOutlineBorder1 = new C.ShowOutlineBorder() { Val = true };
        //	var showKeys1 = new C.ShowKeys() { Val = true };

        //	dataTable1.Append(showHorizontalBorder1);
        //	dataTable1.Append(showVerticalBorder1);
        //	dataTable1.Append(showOutlineBorder1);
        //	dataTable1.Append(showKeys1);

        //	C.ShapeProperties shapeProperties1 = new C.ShapeProperties();

        //	A.Outline outline1 = new A.Outline();
        //	A.NoFill noFill1 = new A.NoFill();

        //	outline1.Append(noFill1);

        //	shapeProperties1.Append(outline1);

        //	plotArea.Append(layout2);
        //	plotArea.Append(areaChart);
        //	plotArea.Append(categoryAxis1);
        //	plotArea.Append(valueAxis1);
        //	plotArea.Append(dataTable1);
        //	plotArea.Append(shapeProperties1);
        //	var plotVisibleOnly1 = new C.PlotVisibleOnly() { Val = true };
        //	var displayBlanksAs1 = new C.DisplayBlanksAs() { Val = C.DisplayBlanksAsValues.Zero };

        //	_chart.Append(title);
        //	_chart.Append(plotArea);
        //	_chart.Append(plotVisibleOnly1);
        //	_chart.Append(displayBlanksAs1);

        //	var textProperties1 = new C.TextProperties();
        //	var bodyProperties2 = new A.BodyProperties();
        //	var listStyle2 = new A.ListStyle();

        //	var paragraph2 = new A.Paragraph();

        //	var paragraphProperties2 = new A.ParagraphProperties();
        //	var defaultRunProperties2 = new A.DefaultRunProperties() { FontSize = 700 };

        //	paragraphProperties2.Append(defaultRunProperties2);
        //	var endParagraphRunProperties2 = new A.EndParagraphRunProperties() { Language = "en-US" };

        //	paragraph2.Append(paragraphProperties2);
        //	paragraph2.Append(endParagraphRunProperties2);

        //	textProperties1.Append(bodyProperties2);
        //	textProperties1.Append(listStyle2);
        //	textProperties1.Append(paragraph2);

        //	var printSettings1 = new C.PrintSettings();
        //	var headerFooter1 = new C.HeaderFooter();
        //	var pageMargins1 = new C.PageMargins() { Left = 0.70000000000000018D, Right = 0.70000000000000018D, Top = 0.75000000000000022D, Bottom = 0.75000000000000022D, Header = 0.3000000000000001D, Footer = 0.3000000000000001D };
        //	var pageSetup1 = new C.PageSetup() { Orientation = C.PageSetupOrientationValues.Landscape };

        //	printSettings1.Append(headerFooter1);
        //	printSettings1.Append(pageMargins1);
        //	printSettings1.Append(pageSetup1);

        //	chartSpace.Append(editingLanguage);
        //	chartSpace.Append(style);
        //	chartSpace.Append(_chart);
        //	chartSpace.Append(textProperties1);
        //	chartSpace.Append(printSettings1);

        //	var chartShapeProperties2 = new ChartShapeProperties();
        //	var outline2 = new DocumentFormat.OpenXml.Drawing.Outline();
        //	var noFill2 = new NoFill();
        //	outline2.Append(noFill2);
        //	chartShapeProperties2.Append(outline2);
        //	//chartSpace.Append(chartShapeProperties2);

        //	chartPart.ChartSpace = chartSpace;
        //}

        // Generates content of drawingsPart1.
        private void GenerateDrawingsPart1Content(DrawingsPart drawingsPart1, Chart chart)
        {
            Xdr.WorksheetDrawing worksheetDrawing1 = new Xdr.WorksheetDrawing();
            worksheetDrawing1.AddNamespaceDeclaration("xdr", "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
            worksheetDrawing1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");

            Xdr.TwoCellAnchor twoCellAnchor1 = new Xdr.TwoCellAnchor();

            Xdr.FromMarker fromMarker1 = new Xdr.FromMarker();
            Xdr.ColumnId   columnId1   = new Xdr.ColumnId();
            columnId1.Text = chart.ColumnFrom.ToString();
            Xdr.ColumnOffset columnOffset1 = new Xdr.ColumnOffset();
            columnOffset1.Text = "0";
            Xdr.RowId rowId1 = new Xdr.RowId();
            rowId1.Text = chart.RowFrom.ToString();
            Xdr.RowOffset rowOffset1 = new Xdr.RowOffset();
            rowOffset1.Text = "0";

            fromMarker1.Append(columnId1);
            fromMarker1.Append(columnOffset1);
            fromMarker1.Append(rowId1);
            fromMarker1.Append(rowOffset1);

            Xdr.ToMarker toMarker1 = new Xdr.ToMarker();
            Xdr.ColumnId columnId2 = new Xdr.ColumnId();
            columnId2.Text = chart.ColumnTo.ToString();
            Xdr.ColumnOffset columnOffset2 = new Xdr.ColumnOffset();
            columnOffset2.Text = "238124";
            Xdr.RowId rowId2 = new Xdr.RowId();
            rowId2.Text = chart.RowTo.ToString();
            Xdr.RowOffset rowOffset2 = new Xdr.RowOffset();
            rowOffset2.Text = "20241";

            toMarker1.Append(columnId2);
            toMarker1.Append(columnOffset2);
            toMarker1.Append(rowId2);
            toMarker1.Append(rowOffset2);

            Xdr.GraphicFrame graphicFrame1 = new Xdr.GraphicFrame()
            {
                Macro = ""
            };

            Xdr.NonVisualGraphicFrameProperties nonVisualGraphicFrameProperties1 = new Xdr.NonVisualGraphicFrameProperties();

            Xdr.NonVisualDrawingProperties nonVisualDrawingProperties1 = new Xdr.NonVisualDrawingProperties()
            {
                Id = (UInt32Value)2U, Name = chart.TableKey
            };

            A.NonVisualDrawingPropertiesExtensionList nonVisualDrawingPropertiesExtensionList1 = new A.NonVisualDrawingPropertiesExtensionList();

            A.NonVisualDrawingPropertiesExtension nonVisualDrawingPropertiesExtension1 = new A.NonVisualDrawingPropertiesExtension()
            {
                Uri = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"
            };

            OpenXmlUnknownElement openXmlUnknownElement1 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<a16:creationId xmlns:a16=\"http://schemas.microsoft.com/office/drawing/2014/main\" id=\"{D4EA194D-E283-4B88-B3BE-83B3557FCE42}\" />");

            nonVisualDrawingPropertiesExtension1.Append(openXmlUnknownElement1);

            nonVisualDrawingPropertiesExtensionList1.Append(nonVisualDrawingPropertiesExtension1);

            nonVisualDrawingProperties1.Append(nonVisualDrawingPropertiesExtensionList1);

            Xdr.NonVisualGraphicFrameDrawingProperties nonVisualGraphicFrameDrawingProperties1 = new Xdr.NonVisualGraphicFrameDrawingProperties();
            A.GraphicFrameLocks graphicFrameLocks1 = new A.GraphicFrameLocks();

            nonVisualGraphicFrameDrawingProperties1.Append(graphicFrameLocks1);

            nonVisualGraphicFrameProperties1.Append(nonVisualDrawingProperties1);
            nonVisualGraphicFrameProperties1.Append(nonVisualGraphicFrameDrawingProperties1);

            Xdr.Transform transform1 = new Xdr.Transform();
            A.Offset      offset1    = new A.Offset()
            {
                X = 0L, Y = 0L
            };
            A.Extents extents1 = new A.Extents()
            {
                Cx = 0L, Cy = 0L
            };

            transform1.Append(offset1);
            transform1.Append(extents1);

            A.Graphic graphic1 = new A.Graphic();

            A.GraphicData graphicData1 = new A.GraphicData()
            {
                Uri = "http://schemas.openxmlformats.org/drawingml/2006/chart"
            };

            C.ChartReference chartReference1 = new C.ChartReference()
            {
                Id = "rId1"
            };
            chartReference1.AddNamespaceDeclaration("c", "http://schemas.openxmlformats.org/drawingml/2006/chart");
            chartReference1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");

            graphicData1.Append(chartReference1);

            graphic1.Append(graphicData1);

            graphicFrame1.Append(nonVisualGraphicFrameProperties1);
            graphicFrame1.Append(transform1);
            graphicFrame1.Append(graphic1);
            Xdr.ClientData clientData1 = new Xdr.ClientData();

            twoCellAnchor1.Append(fromMarker1);
            twoCellAnchor1.Append(toMarker1);
            twoCellAnchor1.Append(graphicFrame1);
            twoCellAnchor1.Append(clientData1);

            worksheetDrawing1.Append(twoCellAnchor1);

            drawingsPart1.WorksheetDrawing = worksheetDrawing1;
        }
Example #22
0
        // Generates content of chartPart1.
        private void GenerateChartPart1Content(ChartPart chartPart1, Chart chart)
        {
            C.ChartSpace chartSpace1 = new C.ChartSpace();
            chartSpace1.AddNamespaceDeclaration("c", "http://schemas.openxmlformats.org/drawingml/2006/chart");
            chartSpace1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
            chartSpace1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            chartSpace1.AddNamespaceDeclaration("c16r2", "http://schemas.microsoft.com/office/drawing/2015/06/chart");
            C.Date1904 date19041 = new C.Date1904()
            {
                Val = false
            };
            C.EditingLanguage editingLanguage1 = new C.EditingLanguage()
            {
                Val = "en-US"
            };
            C.RoundedCorners roundedCorners1 = new C.RoundedCorners()
            {
                Val = true
            };

            AlternateContent alternateContent1 = new AlternateContent();

            alternateContent1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");

            AlternateContentChoice alternateContentChoice1 = new AlternateContentChoice()
            {
                Requires = "c14"
            };

            alternateContentChoice1.AddNamespaceDeclaration("c14", "http://schemas.microsoft.com/office/drawing/2007/8/2/chart");
            C14.Style style1 = new C14.Style()
            {
                Val = 110
            };

            alternateContentChoice1.Append(style1);

            AlternateContentFallback alternateContentFallback1 = new AlternateContentFallback();

            C.Style style2 = new C.Style()
            {
                Val = 10
            };

            alternateContentFallback1.Append(style2);

            alternateContent1.Append(alternateContentChoice1);
            alternateContent1.Append(alternateContentFallback1);

            C.Chart chart1 = new C.Chart();

            C.Title title1 = new C.Title();

            C.ChartText chartText1 = new C.ChartText();

            C.RichText       richText1       = new C.RichText();
            A.BodyProperties bodyProperties1 = new A.BodyProperties();
            A.ListStyle      listStyle1      = new A.ListStyle();

            A.Paragraph paragraph1 = new A.Paragraph();

            A.ParagraphProperties  paragraphProperties1  = new A.ParagraphProperties();
            A.DefaultRunProperties defaultRunProperties1 = new A.DefaultRunProperties();

            paragraphProperties1.Append(defaultRunProperties1);

            A.Run           run1           = new A.Run();
            A.RunProperties runProperties1 = new A.RunProperties()
            {
                Language = "en-US", FontSize = 800
            };
            A.Text text1 = new A.Text();
            text1.Text = "";

            run1.Append(runProperties1);
            run1.Append(text1);

            A.Run           run2           = new A.Run();
            A.RunProperties runProperties2 = new A.RunProperties()
            {
                Language = "en-US", FontSize = 800, Baseline = 0
            };
            A.Text text2 = new A.Text();
            text2.Text = chart.Title;

            run2.Append(runProperties2);
            run2.Append(text2);
            A.EndParagraphRunProperties endParagraphRunProperties1 = new A.EndParagraphRunProperties()
            {
                Language = "en-US", FontSize = 800
            };

            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);
            paragraph1.Append(run2);
            paragraph1.Append(endParagraphRunProperties1);

            richText1.Append(bodyProperties1);
            richText1.Append(listStyle1);
            richText1.Append(paragraph1);

            chartText1.Append(richText1);

            C.Layout layout1 = new C.Layout();

            C.ManualLayout manualLayout1 = new C.ManualLayout();
            C.LeftMode     leftMode1     = new C.LeftMode()
            {
                Val = C.LayoutModeValues.Edge
            };
            C.TopMode topMode1 = new C.TopMode()
            {
                Val = C.LayoutModeValues.Edge
            };
            C.Left left1 = new C.Left()
            {
                Val = 0.14936699324798144D
            };
            C.Top top1 = new C.Top()
            {
                Val = 7.5867300613079197E-2D
            };

            manualLayout1.Append(leftMode1);
            manualLayout1.Append(topMode1);
            manualLayout1.Append(left1);
            manualLayout1.Append(top1);

            layout1.Append(manualLayout1);
            C.Overlay overlay1 = new C.Overlay()
            {
                Val = true
            };

            title1.Append(chartText1);
            title1.Append(layout1);
            title1.Append(overlay1);
            C.AutoTitleDeleted autoTitleDeleted1 = new C.AutoTitleDeleted()
            {
                Val = false
            };

            C.PlotArea plotArea1 = new C.PlotArea();

            C.Layout layout2 = new C.Layout();

            C.ManualLayout manualLayout2 = new C.ManualLayout();
            C.LayoutTarget layoutTarget1 = new C.LayoutTarget()
            {
                Val = C.LayoutTargetValues.Inner
            };
            C.LeftMode leftMode2 = new C.LeftMode()
            {
                Val = C.LayoutModeValues.Edge
            };
            C.TopMode topMode2 = new C.TopMode()
            {
                Val = C.LayoutModeValues.Edge
            };
            C.Left left2 = new C.Left()
            {
                Val = 0.10245464404093282D
            };
            C.Top top2 = new C.Top()
            {
                Val = 4.7416814491091287E-2D
            };
            C.Width width1 = new C.Width()
            {
                Val = 0.88919609910728359D
            };
            C.Height height1 = new C.Height()
            {
                Val = 0.86D
            };

            manualLayout2.Append(layoutTarget1);
            manualLayout2.Append(leftMode2);
            manualLayout2.Append(topMode2);
            manualLayout2.Append(left2);
            manualLayout2.Append(top2);
            manualLayout2.Append(width1);
            manualLayout2.Append(height1);

            layout2.Append(manualLayout2);

            C.AreaChart areaChart1 = new C.AreaChart();
            C.Grouping  grouping1  = new C.Grouping()
            {
                Val = C.GroupingValues.Standard
            };
            C.VaryColors varyColors1 = new C.VaryColors()
            {
                Val = true
            };

            C.AreaChartSeries areaChartSeries1 = new C.AreaChartSeries();
            C.Index           index1           = new C.Index()
            {
                Val = (UInt32Value)0U
            };
            C.Order order1 = new C.Order()
            {
                Val = (UInt32Value)0U
            };

            C.SeriesText   seriesText1   = new C.SeriesText();
            C.NumericValue numericValue1 = new C.NumericValue();
            numericValue1.Text = chart.LegendTitle;

            seriesText1.Append(numericValue1);

            C.CategoryAxisData categoryAxisData1 = new C.CategoryAxisData();

            C.NumberReference numberReference1 = new C.NumberReference();

            C.NumRefExtensionList numRefExtensionList1 = new C.NumRefExtensionList();

            C.NumRefExtension numRefExtension1 = new C.NumRefExtension()
            {
                Uri = "{02D57815-91ED-43cb-92C2-25804820EDAC}"
            };
            numRefExtension1.AddNamespaceDeclaration("c15", "http://schemas.microsoft.com/office/drawing/2012/chart");

            C15.FullReference        fullReference1        = new C15.FullReference();
            C15.SequenceOfReferences sequenceOfReferences1 = new C15.SequenceOfReferences();
            sequenceOfReferences1.Text = chart.AxisX;

            fullReference1.Append(sequenceOfReferences1);

            numRefExtension1.Append(fullReference1);

            numRefExtensionList1.Append(numRefExtension1);
            C.Formula formula1 = new C.Formula();
            formula1.Text = chart.AxisX;

            C.NumberingCache numberingCache1 = new C.NumberingCache();
            C.FormatCode     formatCode1     = new C.FormatCode();
            formatCode1.Text = "General";
            C.PointCount pointCount1 = new C.PointCount()
            {
                Val = (UInt32Value)(uint)chart.Labels.Count
            };

            numberingCache1.Append(formatCode1);
            numberingCache1.Append(pointCount1);

            for (uint i = 0; i < chart.Labels.Count; i++)
            {
                C.NumericPoint numericPoint1 = new C.NumericPoint()
                {
                    Index = (UInt32Value)i
                };
                C.NumericValue numericValue2 = new C.NumericValue();
                numericValue2.Text = chart.Labels[(int)i];

                numericPoint1.Append(numericValue2);

                numberingCache1.Append(numericPoint1);
            }

            numberReference1.Append(numRefExtensionList1);
            numberReference1.Append(formula1);
            numberReference1.Append(numberingCache1);

            categoryAxisData1.Append(numberReference1);

            C.Values values1 = new C.Values();

            C.NumberReference numberReference2 = new C.NumberReference();

            C.NumRefExtensionList numRefExtensionList2 = new C.NumRefExtensionList();

            C.NumRefExtension numRefExtension2 = new C.NumRefExtension()
            {
                Uri = "{02D57815-91ED-43cb-92C2-25804820EDAC}"
            };
            numRefExtension2.AddNamespaceDeclaration("c15", "http://schemas.microsoft.com/office/drawing/2012/chart");

            C15.FullReference        fullReference2        = new C15.FullReference();
            C15.SequenceOfReferences sequenceOfReferences2 = new C15.SequenceOfReferences();
            sequenceOfReferences2.Text = chart.AxisY;

            fullReference2.Append(sequenceOfReferences2);

            numRefExtension2.Append(fullReference2);

            numRefExtensionList2.Append(numRefExtension2);
            C.Formula formula2 = new C.Formula();
            formula2.Text = chart.AxisY;

            C.NumberingCache numberingCache2 = new C.NumberingCache();
            C.FormatCode     formatCode2     = new C.FormatCode();
            formatCode2.Text = "0.00%";
            C.PointCount pointCount2 = new C.PointCount()
            {
                Val = (UInt32Value)(uint)chart.Values.Count
            };

            numberingCache2.Append(formatCode2);
            numberingCache2.Append(pointCount2);

            for (uint i = 0; i < chart.Values.Count; i++)
            {
                C.NumericPoint numericPoint27 = new C.NumericPoint()
                {
                    Index = (UInt32Value)i
                };
                C.NumericValue numericValue28 = new C.NumericValue();
                numericValue28.Text = chart.Values[(int)i];

                numericPoint27.Append(numericValue28);

                numberingCache2.Append(numericPoint27);
            }

            numberReference2.Append(numRefExtensionList2);
            numberReference2.Append(formula2);
            numberReference2.Append(numberingCache2);

            values1.Append(numberReference2);

            C.AreaSerExtensionList areaSerExtensionList1 = new C.AreaSerExtensionList();

            C.AreaSerExtension areaSerExtension1 = new C.AreaSerExtension()
            {
                Uri = "{C3380CC4-5D6E-409C-BE32-E72D297353CC}"
            };
            areaSerExtension1.AddNamespaceDeclaration("c16", "http://schemas.microsoft.com/office/drawing/2014/chart");

            OpenXmlUnknownElement openXmlUnknownElement2 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<c16:uniqueId val=\"{00000000-69FF-4CCD-9302-CEC5CC8046DF}\" xmlns:c16=\"http://schemas.microsoft.com/office/drawing/2014/chart\" />");

            areaSerExtension1.Append(openXmlUnknownElement2);

            areaSerExtensionList1.Append(areaSerExtension1);

            areaChartSeries1.Append(index1);
            areaChartSeries1.Append(order1);
            areaChartSeries1.Append(seriesText1);
            areaChartSeries1.Append(categoryAxisData1);
            areaChartSeries1.Append(values1);
            areaChartSeries1.Append(areaSerExtensionList1);

            C.DataLabels    dataLabels1    = new C.DataLabels();
            C.ShowLegendKey showLegendKey1 = new C.ShowLegendKey()
            {
                Val = false
            };
            C.ShowValue showValue1 = new C.ShowValue()
            {
                Val = false
            };
            C.ShowCategoryName showCategoryName1 = new C.ShowCategoryName()
            {
                Val = false
            };
            C.ShowSeriesName showSeriesName1 = new C.ShowSeriesName()
            {
                Val = false
            };
            C.ShowPercent showPercent1 = new C.ShowPercent()
            {
                Val = false
            };
            C.ShowBubbleSize showBubbleSize1 = new C.ShowBubbleSize()
            {
                Val = false
            };

            dataLabels1.Append(showLegendKey1);
            dataLabels1.Append(showValue1);
            dataLabels1.Append(showCategoryName1);
            dataLabels1.Append(showSeriesName1);
            dataLabels1.Append(showPercent1);
            dataLabels1.Append(showBubbleSize1);
            C.AxisId axisId1 = new C.AxisId()
            {
                Val = (UInt32Value)78173696U
            };
            C.AxisId axisId2 = new C.AxisId()
            {
                Val = (UInt32Value)78175232U
            };

            areaChart1.Append(grouping1);
            areaChart1.Append(varyColors1);
            areaChart1.Append(areaChartSeries1);
            areaChart1.Append(dataLabels1);
            areaChart1.Append(axisId1);
            areaChart1.Append(axisId2);

            C.CategoryAxis categoryAxis1 = new C.CategoryAxis();
            C.AxisId       axisId3       = new C.AxisId()
            {
                Val = (UInt32Value)78173696U
            };

            C.Scaling     scaling1     = new C.Scaling();
            C.Orientation orientation1 = new C.Orientation()
            {
                Val = C.OrientationValues.MinMax
            };

            scaling1.Append(orientation1);
            C.Delete delete1 = new C.Delete()
            {
                Val = true
            };
            C.AxisPosition axisPosition1 = new C.AxisPosition()
            {
                Val = C.AxisPositionValues.Bottom
            };
            C.NumberingFormat numberingFormat1 = new C.NumberingFormat()
            {
                FormatCode = "General", SourceLinked = true
            };
            C.MajorTickMark majorTickMark1 = new C.MajorTickMark()
            {
                Val = C.TickMarkValues.None
            };
            C.MinorTickMark minorTickMark1 = new C.MinorTickMark()
            {
                Val = C.TickMarkValues.Cross
            };
            C.TickLabelPosition tickLabelPosition1 = new C.TickLabelPosition()
            {
                Val = C.TickLabelPositionValues.NextTo
            };
            C.CrossingAxis crossingAxis1 = new C.CrossingAxis()
            {
                Val = (UInt32Value)78175232U
            };
            C.Crosses crosses1 = new C.Crosses()
            {
                Val = C.CrossesValues.AutoZero
            };
            C.AutoLabeled autoLabeled1 = new C.AutoLabeled()
            {
                Val = true
            };
            C.LabelAlignment labelAlignment1 = new C.LabelAlignment()
            {
                Val = C.LabelAlignmentValues.Center
            };
            C.LabelOffset labelOffset1 = new C.LabelOffset()
            {
                Val = (UInt16Value)100U
            };
            C.NoMultiLevelLabels noMultiLevelLabels1 = new C.NoMultiLevelLabels()
            {
                Val = true
            };

            categoryAxis1.Append(axisId3);
            categoryAxis1.Append(scaling1);
            categoryAxis1.Append(delete1);
            categoryAxis1.Append(axisPosition1);
            categoryAxis1.Append(numberingFormat1);
            categoryAxis1.Append(majorTickMark1);
            categoryAxis1.Append(minorTickMark1);
            categoryAxis1.Append(tickLabelPosition1);
            categoryAxis1.Append(crossingAxis1);
            categoryAxis1.Append(crosses1);
            categoryAxis1.Append(autoLabeled1);
            categoryAxis1.Append(labelAlignment1);
            categoryAxis1.Append(labelOffset1);
            categoryAxis1.Append(noMultiLevelLabels1);

            C.ValueAxis valueAxis1 = new C.ValueAxis();
            C.AxisId    axisId4    = new C.AxisId()
            {
                Val = (UInt32Value)78175232U
            };

            C.Scaling     scaling2     = new C.Scaling();
            C.Orientation orientation2 = new C.Orientation()
            {
                Val = C.OrientationValues.MinMax
            };

            scaling2.Append(orientation2);
            C.Delete delete2 = new C.Delete()
            {
                Val = true
            };
            C.AxisPosition axisPosition2 = new C.AxisPosition()
            {
                Val = C.AxisPositionValues.Left
            };
            C.MajorGridlines  majorGridlines1  = new C.MajorGridlines();
            C.NumberingFormat numberingFormat2 = new C.NumberingFormat()
            {
                FormatCode = "General", SourceLinked = true
            };
            C.MajorTickMark majorTickMark2 = new C.MajorTickMark()
            {
                Val = C.TickMarkValues.None
            };
            C.MinorTickMark minorTickMark2 = new C.MinorTickMark()
            {
                Val = C.TickMarkValues.Cross
            };
            C.TickLabelPosition tickLabelPosition2 = new C.TickLabelPosition()
            {
                Val = C.TickLabelPositionValues.NextTo
            };
            C.CrossingAxis crossingAxis2 = new C.CrossingAxis()
            {
                Val = (UInt32Value)78173696U
            };
            C.Crosses crosses2 = new C.Crosses()
            {
                Val = C.CrossesValues.AutoZero
            };
            C.CrossBetween crossBetween1 = new C.CrossBetween()
            {
                Val = C.CrossBetweenValues.MidpointCategory
            };

            valueAxis1.Append(axisId4);
            valueAxis1.Append(scaling2);
            valueAxis1.Append(delete2);
            valueAxis1.Append(axisPosition2);
            valueAxis1.Append(majorGridlines1);
            valueAxis1.Append(numberingFormat2);
            valueAxis1.Append(majorTickMark2);
            valueAxis1.Append(minorTickMark2);
            valueAxis1.Append(tickLabelPosition2);
            valueAxis1.Append(crossingAxis2);
            valueAxis1.Append(crosses2);
            valueAxis1.Append(crossBetween1);

            C.DataTable            dataTable1            = new C.DataTable();
            C.ShowHorizontalBorder showHorizontalBorder1 = new C.ShowHorizontalBorder()
            {
                Val = true
            };
            C.ShowVerticalBorder showVerticalBorder1 = new C.ShowVerticalBorder()
            {
                Val = true
            };
            C.ShowOutlineBorder showOutlineBorder1 = new C.ShowOutlineBorder()
            {
                Val = true
            };
            C.ShowKeys showKeys1 = new C.ShowKeys()
            {
                Val = true
            };

            dataTable1.Append(showHorizontalBorder1);
            dataTable1.Append(showVerticalBorder1);
            dataTable1.Append(showOutlineBorder1);
            dataTable1.Append(showKeys1);

            C.ShapeProperties shapeProperties1 = new C.ShapeProperties();

            A.Outline outline1 = new A.Outline();
            A.NoFill  noFill1  = new A.NoFill();

            outline1.Append(noFill1);

            shapeProperties1.Append(outline1);

            plotArea1.Append(layout2);
            plotArea1.Append(areaChart1);
            plotArea1.Append(categoryAxis1);
            plotArea1.Append(valueAxis1);
            plotArea1.Append(dataTable1);
            plotArea1.Append(shapeProperties1);
            C.PlotVisibleOnly plotVisibleOnly1 = new C.PlotVisibleOnly()
            {
                Val = true
            };
            C.DisplayBlanksAs displayBlanksAs1 = new C.DisplayBlanksAs()
            {
                Val = C.DisplayBlanksAsValues.Zero
            };
            C.ShowDataLabelsOverMaximum showDataLabelsOverMaximum1 = new C.ShowDataLabelsOverMaximum()
            {
                Val = true
            };

            chart1.Append(title1);
            chart1.Append(autoTitleDeleted1);
            chart1.Append(plotArea1);
            chart1.Append(plotVisibleOnly1);
            chart1.Append(displayBlanksAs1);
            chart1.Append(showDataLabelsOverMaximum1);

            C.ShapeProperties shapeProperties2 = new C.ShapeProperties();

            A.Outline outline2 = new A.Outline();
            A.NoFill  noFill2  = new A.NoFill();

            outline2.Append(noFill2);

            shapeProperties2.Append(outline2);

            C.TextProperties textProperties1 = new C.TextProperties();
            A.BodyProperties bodyProperties2 = new A.BodyProperties();
            A.ListStyle      listStyle2      = new A.ListStyle();

            A.Paragraph paragraph2 = new A.Paragraph();

            A.ParagraphProperties  paragraphProperties2  = new A.ParagraphProperties();
            A.DefaultRunProperties defaultRunProperties2 = new A.DefaultRunProperties()
            {
                FontSize = 700
            };

            paragraphProperties2.Append(defaultRunProperties2);
            A.EndParagraphRunProperties endParagraphRunProperties2 = new A.EndParagraphRunProperties()
            {
                Language = "en-US"
            };

            paragraph2.Append(paragraphProperties2);
            paragraph2.Append(endParagraphRunProperties2);

            textProperties1.Append(bodyProperties2);
            textProperties1.Append(listStyle2);
            textProperties1.Append(paragraph2);

            C.PrintSettings printSettings1 = new C.PrintSettings();
            C.HeaderFooter  headerFooter1  = new C.HeaderFooter();
            C.PageMargins   pageMargins1   = new C.PageMargins()
            {
                Left = 0.70000000000000018D, Right = 0.70000000000000018D, Top = 0.75000000000000022D, Bottom = 0.75000000000000022D, Header = 0.3000000000000001D, Footer = 0.3000000000000001D
            };
            C.PageSetup pageSetup1 = new C.PageSetup()
            {
                Orientation = C.PageSetupOrientationValues.Landscape
            };

            printSettings1.Append(headerFooter1);
            printSettings1.Append(pageMargins1);
            printSettings1.Append(pageSetup1);

            chartSpace1.Append(date19041);
            chartSpace1.Append(editingLanguage1);
            chartSpace1.Append(roundedCorners1);
            chartSpace1.Append(alternateContent1);
            chartSpace1.Append(chart1);
            chartSpace1.Append(shapeProperties2);
            chartSpace1.Append(textProperties1);
            chartSpace1.Append(printSettings1);

            chartPart1.ChartSpace = chartSpace1;
        }
Example #23
0
        private static void GenerateWorkbookStylesPartContent(WorkbookStylesPart workbookStylesPart1)
        {
            Stylesheet stylesheet1 = new Stylesheet()
            {
                MCAttributes = new MarkupCompatibilityAttributes()
                {
                    Ignorable = "x14ac x16r2 xr"
                }
            };

            stylesheet1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            stylesheet1.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac");
            stylesheet1.AddNamespaceDeclaration("x16r2", "http://schemas.microsoft.com/office/spreadsheetml/2015/02/main");
            stylesheet1.AddNamespaceDeclaration("xr", "http://schemas.microsoft.com/office/spreadsheetml/2014/revision");

            Fonts fonts1 = new Fonts()
            {
                Count = (UInt32Value)1U, KnownFonts = true
            };

            Font     font1     = new Font();
            FontSize fontSize1 = new FontSize()
            {
                Val = 11D
            };
            Color color1 = new Color()
            {
                Theme = (UInt32Value)1U
            };
            FontName fontName1 = new FontName()
            {
                Val = "Calibri"
            };
            FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering()
            {
                Val = 2
            };
            FontScheme fontScheme1 = new FontScheme()
            {
                Val = FontSchemeValues.Minor
            };

            font1.Append(fontSize1);
            font1.Append(color1);
            font1.Append(fontName1);
            font1.Append(fontFamilyNumbering1);
            font1.Append(fontScheme1);

            fonts1.Append(font1);

            Fills fills1 = new Fills()
            {
                Count = (UInt32Value)2U
            };

            Fill        fill1        = new Fill();
            PatternFill patternFill1 = new PatternFill()
            {
                PatternType = PatternValues.None
            };

            fill1.Append(patternFill1);

            Fill        fill2        = new Fill();
            PatternFill patternFill2 = new PatternFill()
            {
                PatternType = PatternValues.Gray125
            };

            fill2.Append(patternFill2);

            fills1.Append(fill1);
            fills1.Append(fill2);

            Borders borders1 = new Borders()
            {
                Count = (UInt32Value)1U
            };

            Border         border1         = new Border();
            LeftBorder     leftBorder1     = new LeftBorder();
            RightBorder    rightBorder1    = new RightBorder();
            TopBorder      topBorder1      = new TopBorder();
            BottomBorder   bottomBorder1   = new BottomBorder();
            DiagonalBorder diagonalBorder1 = new DiagonalBorder();

            border1.Append(leftBorder1);
            border1.Append(rightBorder1);
            border1.Append(topBorder1);
            border1.Append(bottomBorder1);
            border1.Append(diagonalBorder1);

            borders1.Append(border1);

            CellStyleFormats cellStyleFormats1 = new CellStyleFormats()
            {
                Count = (UInt32Value)1U
            };
            CellFormat cellFormat1 = new CellFormat()
            {
                NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U
            };

            cellStyleFormats1.Append(cellFormat1);

            CellFormats cellFormats1 = new CellFormats()
            {
                Count = (UInt32Value)2U
            };
            CellFormat cellFormat2 = new CellFormat()
            {
                NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U
            };
            CellFormat cellFormat3 = new CellFormat()
            {
                NumberFormatId = (UInt32Value)14U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true
            };

            cellFormats1.Append(cellFormat2);
            cellFormats1.Append(cellFormat3);

            CellStyles cellStyles1 = new CellStyles()
            {
                Count = (UInt32Value)1U
            };
            CellStyle cellStyle1 = new CellStyle()
            {
                Name = "Normal", FormatId = (UInt32Value)0U, BuiltinId = (UInt32Value)0U
            };

            cellStyles1.Append(cellStyle1);
            DifferentialFormats differentialFormats1 = new DifferentialFormats()
            {
                Count = (UInt32Value)0U
            };
            TableStyles tableStyles1 = new TableStyles()
            {
                Count = (UInt32Value)0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16"
            };

            StylesheetExtensionList stylesheetExtensionList1 = new StylesheetExtensionList();

            StylesheetExtension stylesheetExtension1 = new StylesheetExtension()
            {
                Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
            };

            stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");

            StylesheetExtension stylesheetExtension2 = new StylesheetExtension()
            {
                Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
            };

            stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");

            OpenXmlUnknownElement openXmlUnknownElement4 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<x15:timelineStyles defaultTimelineStyle=\"TimeSlicerStyleLight1\" xmlns:x15=\"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main\" />");

            stylesheetExtension2.Append(openXmlUnknownElement4);

            stylesheetExtensionList1.Append(stylesheetExtension1);
            stylesheetExtensionList1.Append(stylesheetExtension2);

            stylesheet1.Append(fonts1);
            stylesheet1.Append(fills1);
            stylesheet1.Append(borders1);
            stylesheet1.Append(cellStyleFormats1);
            stylesheet1.Append(cellFormats1);
            stylesheet1.Append(cellStyles1);
            stylesheet1.Append(differentialFormats1);
            stylesheet1.Append(tableStyles1);
            stylesheet1.Append(stylesheetExtensionList1);

            workbookStylesPart1.Stylesheet = stylesheet1;
        }
Example #24
0
        private static void UpdatePowerPointBlock(ReportData client, OpenXmlPartContainer container, OpenXmlElement block, TableDefinition content, Dictionary <string, string> options)
        {
            if (null != content && block is OXP.GraphicFrame)
            {
                var       randomValue = new Random();
                OXD.Table initTable   = block.Descendants <OXD.Table>().FirstOrDefault();
                if (null == initTable)
                {
                    return;
                }
                try
                {
                    OXD.Table    table              = initTable.CloneNode(true) as OXD.Table;
                    OXD.TableRow headerRowTemplate  = table?.Descendants <OXD.TableRow>().First().CloneNode(true) as OXD.TableRow;
                    OXD.TableRow contentRowTemplate = table?.Descendants <OXD.TableRow>().Skip(1).First().CloneNode(true) as OXD.TableRow;

                    ModifyPowerPointRowTextContent(headerRowTemplate, string.Empty);
                    ModifyPowerPointRowTextContent(contentRowTemplate, string.Empty);

                    #region Column Number Management
                    List <OXD.GridColumn> columns = table?.TableGrid.Descendants <OXD.GridColumn>().ToList();
                    if (columns != null && columns.Count < content.NbColumns)
                    {
                        int nbNewColumn = content.NbColumns - columns.Count;
                        for (int i = 0, lim = nbNewColumn; i < lim; i++)
                        {
                            AddNewGridColumn(table.TableGrid, headerRowTemplate, contentRowTemplate);
                        }
                    }
                    else if (columns != null && columns.Count > content.NbColumns)
                    {
                        for (int i = content.NbColumns, lim = columns.Count; i < lim; i++)
                        {
                            RemoveLastGridColumn(table.TableGrid);
                        }
                    }
                    #endregion Column Number Management

                    int idx   = 0;
                    int nbrow = 0;
                    List <OXD.TableCell> headerCells  = headerRowTemplate?.Descendants <OXD.TableCell>().Select(_ => _.CloneNode(true) as OXD.TableCell).ToList();
                    List <OXD.TableCell> contentCells = contentRowTemplate?.Descendants <OXD.TableCell>().Select(_ => _.CloneNode(true) as OXD.TableCell).ToList();
                    headerRowTemplate?.RemoveAllChildren <OXD.TableCell>();
                    OXD.TableRow row = headerRowTemplate;

                    table?.RemoveAllChildren <OXD.TableRow>();
                    for (int i = 0; i < content.Data.Count(); i++)
                    {
                        string        item = content.Data.ToArray()[i];
                        OXD.TableCell cell;
                        if (content.HasColumnHeaders && 0 == nbrow)
                        {
                            cell = headerCells?[idx].CloneNode(true) as OXD.TableCell;
                        }
                        else
                        {
                            cell = contentCells?[idx].CloneNode(true) as OXD.TableCell;
                        }
                        ModifyPowerPointCellTextContent(cell, item);

                        if (content.HasCellsAttributes())
                        {
                            CellAttributes attributes = content.CellsAttributes.FirstOrDefault(a => a.Index == i);
                            if (attributes?.BackgroundColor != null)
                            {
                                Color myColor = attributes.BackgroundColor;
                                OXD.RgbColorModelHex backColor = new OXD.RgbColorModelHex()
                                {
                                    Val = $"{myColor.R:X2}{myColor.G:X2}{myColor.B:X2}"
                                };
                                OXD.SolidFill solidFill = new OXD.SolidFill();
                                solidFill.Append(backColor);
                                OXD.TableCellProperties props     = cell?.Descendants <OXD.TableCellProperties>().FirstOrDefault();
                                OXD.TableCellProperties new_props = (props != null) ? props.CloneNode(true) as OXD.TableCellProperties : new OXD.TableCellProperties();

                                OXD.SolidFill oldFill = new_props?.Descendants <OXD.SolidFill>().FirstOrDefault();
                                oldFill?.Remove();
                                new_props?.InsertAfter(solidFill, new_props.LastChild);
                                if (props != null)
                                {
                                    cell.ReplaceChild(new_props, props);
                                }
                                else
                                {
                                    cell?.AppendChild(new_props);
                                }
                            }
                        }

                        //row.Append(cell); => in office 2016, element <extLst> should absolutely be in the latest position in a row
                        row?.InsertBefore(cell, row.Descendants <OXD.ExtensionList>().FirstOrDefault());

                        OXD.ExtensionList init_extlst = row?.Descendants <OXD.ExtensionList>().FirstOrDefault();
                        if (init_extlst != null)
                        {
                            OXD.Extension         init_ext   = init_extlst.Descendants <OXD.Extension>().FirstOrDefault();
                            OpenXmlUnknownElement init_rowId = init_ext?.GetFirstChild <OpenXmlUnknownElement>();
                            OpenXmlUnknownElement new_rowId  = init_rowId?.CloneNode(true) as OpenXmlUnknownElement;
                            if (new_rowId != null)
                            {
                                OpenXmlAttribute val = new_rowId.GetAttributes().FirstOrDefault();
                                val.Value = randomValue.Next().ToString();
                                new_rowId.SetAttribute(val);
                                init_ext.ReplaceChild(new_rowId, init_rowId);
                            }
                        }

                        idx = ++idx % content.NbColumns;
                        if (0 != idx)
                        {
                            continue;
                        }
                        // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                        if (null != row)
                        {
                            table.Append(row);
                            nbrow++;
                        }
                        row = contentRowTemplate?.CloneNode(true) as OXD.TableRow;
                        row?.RemoveAllChildren <OXD.TableCell>();
                    }
                    initTable.Parent.ReplaceChild(table, initTable);
                }
                catch (Exception exception)
                {
                    LogHelper.Instance.LogErrorFormat("An unhandled exception was thrown during table block content generation : '{0}'", exception.ToString());
                    if (initTable.Descendants <OXD.TableRow>() != null && !initTable.Descendants <OXD.TableRow>().Any())
                    {
                        foreach (var row in initTable.Descendants <OXD.TableRow>().Skip(1))
                        {
                            ModifyPowerPointRowTextContent(row, string.Empty);
                        }
                    }
                }
            }
            else
            {
                LogHelper.Instance.LogErrorFormat("Impossible to load data in table block with a block source of type \"{0}\"", block?.GetType().ToString() ?? "null");
            }
        }