예제 #1
0
        public void ParseDocument()
        {
            foreach (var part in document.AllParts().Where(p => p.RootElement != null))
            {
                foreach (var item in part.RootElement.Descendants())
                {
                    if (item is W.Paragraph wp)
                    {
                        ReplaceRuns(wp, new WordprocessingNodeProvider());
                    }

                    if (item is D.Paragraph dp)
                    {
                        ReplaceRuns(dp, new DrawingNodeProvider());
                    }

                    if (item is S.SharedStringItem s)
                    {
                        ReplaceRuns(s, new SpreadsheetNodeProvider());
                    }
                }


                TableBinder.ValidateTables(part, this.template, this.Errors);
            }
        }
예제 #2
0
        internal void RenderNodes()
        {
            var parameters = new WordTemplateParameters(this.entity, this.culture, this.dicTokenColumn, this.table.Rows)
            {
                SystemWordTemplate = systemWordTemplate,
                Template           = template,
            };

            foreach (var part in document.AllParts().Where(p => p.RootElement != null))
            {
                var root      = part.RootElement;
                var baseNodes = root.Descendants <BaseNode>().ToList(); //eager
                foreach (var node in baseNodes)
                {
                    node.RenderNode(parameters);
                }

                TableBinder.ProcessTables(part, parameters);

                foreach (var item in root.Descendants <D.Charts.ExternalData>().ToList())
                {
                    item.Remove();
                }
            }

            foreach (var item in document.AllParts().OfType <EmbeddedPackagePart>().ToList())
            {
                foreach (var p in item.GetParentParts().ToList())
                {
                    p.DeletePart(item);
                }
            }
        }