当前位置: 首页>>代码示例>>C#>>正文


C# Packaging.MainDocumentPart类代码示例

本文整理汇总了C#中DocumentFormat.OpenXml.Packaging.MainDocumentPart的典型用法代码示例。如果您正苦于以下问题:C# MainDocumentPart类的具体用法?C# MainDocumentPart怎么用?C# MainDocumentPart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MainDocumentPart类属于DocumentFormat.OpenXml.Packaging命名空间,在下文中一共展示了MainDocumentPart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertContentToParagraphs

 private IList<OpenXmlCompositeElement> ConvertContentToParagraphs(MainDocumentPart mainDocumentPart)
 {
     var converter = new HtmlConverter(mainDocumentPart) { RenderPreAsTable = false };
     return converter.Parse(_content
         .Replace("<img", "<img style=\"max-width:550;\"")
         .Replace("<pre><code>", "<p class=\"codesnippet\"><pre>")
         .Replace("</code></pre>", "</pre></p>")
         .Replace("<code>", "<span class=\"inlinecodesnippet\">")
         .Replace("</code>", "</span>"));
 }
开发者ID:Geaz,项目名称:SharpDox.Plugins.Word,代码行数:10,代码来源:RichText.cs

示例2: AppendTo

        public override void AppendTo(OpenXmlElement openXmlNode, MainDocumentPart mainDocumentPart)
        {
            _mainDocumentPart = mainDocumentPart;

            var imagePart = CreateImagePart();
            openXmlNode.Append(CreateImageElement(mainDocumentPart.GetIdOfPart(imagePart), Path.GetFileName(_content)));
        }
开发者ID:Geaz,项目名称:SharpDox.Plugins.Word,代码行数:7,代码来源:Image.cs

示例3: GetContentControl

        /// <summary>
        /// Get ContentControl from word document
        /// </summary>
        /// <param name="pDoc">Document mainpart</param>
        /// <param name="pTag">ContentControl tag to find</param>
        /// <returns>The ContentControl</returns>
        public static SdtBlock GetContentControl(MainDocumentPart pDoc, string pTag)
        {
            SdtBlock cc = pDoc.Document.Body.Descendants<SdtBlock>().Where
                     (r => r.SdtProperties.GetFirstChild<Tag>().Val == pTag).Single();

            return cc;
        }
开发者ID:shaanino,项目名称:dmt,代码行数:13,代码来源:OpenXmlHelpers.cs

示例4: GetCustomXmlPart

        /// <summary>
        /// Gets the custom XML part.
        /// </summary>
        /// <param name="mainDocumentPart">The main document part.</param>
        /// <returns></returns>
        public CustomXmlPart GetCustomXmlPart(MainDocumentPart mainDocumentPart)
        {
            if (mainDocumentPart == null)
            {
                throw new ArgumentNullException("mainDocumentPart");
            }

            CustomXmlPart result = null;

            foreach (CustomXmlPart part in mainDocumentPart.CustomXmlParts)
            {
                using (XmlTextReader reader = new XmlTextReader(part.GetStream(FileMode.Open, FileAccess.Read)))
                {
                    reader.MoveToContent();
                    bool exists = reader.NamespaceURI.Equals(this.namespaceUri);

                    if (exists)
                    {
                        result = part;
                        break;
                    }
                }
            }

            return result;
        }
开发者ID:shenoyroopesh,项目名称:Gama,代码行数:31,代码来源:CustomXmlPartCore.cs

示例5: NumberingListStyleCollection

 public NumberingListStyleCollection(MainDocumentPart mainPart)
 {
     this.mainPart = mainPart;
     this.absNumId = -1;
     this.numInstances = new Stack<Int32>();
     InitNumberingIds();
 }
开发者ID:rexyanglucky,项目名称:uba,代码行数:7,代码来源:NumberingListStyleCollection.cs

示例6: GetNameToValueCollectionFromElementForType

        /// <summary>
        /// Gets the type of the name to value collection from element for.
        /// </summary>
        /// <param name="mainDocumentPart">The main document part.</param>
        /// <param name="elementName">Name of the element.</param>
        /// <param name="forNodeType">Type of for node.</param>
        /// <returns></returns>
        public Dictionary<string, string> GetNameToValueCollectionFromElementForType(MainDocumentPart mainDocumentPart, string elementName, NodeType forNodeType)
        {
            Dictionary<string, string> nameToValueCollection = new Dictionary<string, string>();
            CustomXmlPart customXmlPart = this.customXmlPartCore.GetCustomXmlPart(mainDocumentPart);

            if (customXmlPart != null)
            {
                XElement element = this.customXmlPartCore.GetFirstElementFromCustomXmlPart(customXmlPart, elementName);

                if (element != null)
                {
                    if (forNodeType == NodeType.Element)
                    {
                        foreach (XElement elem in element.Elements())
                        {
                            nameToValueCollection.Add(elem.Name.LocalName, elem.Nodes().Where(node => node.NodeType == XmlNodeType.Element).FirstOrDefault().ToString());
                        }
                    }
                    else if (forNodeType == NodeType.Attribute)
                    {
                        foreach (XAttribute attr in element.Attributes())
                        {
                            nameToValueCollection.Add(attr.Name.LocalName, attr.Value);
                        }
                    }
                }
            }

            return nameToValueCollection;
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:37,代码来源:CustomXmlPartHelper.cs

示例7: GenerateParagraphWithHyperLink

        /// <summary>
        /// Generates a hyperlink and embed it
        /// in a paragraph tag
        /// </summary>
        /// <param name="mainDocPart">The main doc part.</param>
        /// <param name="hyperLink">The hyper link.</param>
        /// <returns></returns>
        public static Paragraph GenerateParagraphWithHyperLink(MainDocumentPart mainDocPart, String hyperLink)
        {
            //this will be display as
            //the text
            String urlLabel = hyperLink;

            //build the hyperlink
            //file:// ensure that document does not corrupt
            System.Uri uri = new Uri(@"file://" + hyperLink);

            //add it to the document
            HyperlinkRelationship rel = mainDocPart.AddHyperlinkRelationship(uri, true);

            //get the hyperlink id
            string relationshipId = rel.Id;

            //create the new paragraph tag
            Paragraph newParagraph = new Paragraph(
                new DocumentFormat.OpenXml.Wordprocessing.Hyperlink(
                    new ProofError() { Type = ProofingErrorValues.GrammarStart },
                    new DocumentFormat.OpenXml.Wordprocessing.Run(
                        new DocumentFormat.OpenXml.Wordprocessing.RunProperties(
                            new RunStyle() { Val = "Hyperlink" }),
                            new DocumentFormat.OpenXml.Wordprocessing.Text(urlLabel)
                            )) { History = OnOffValue.FromBoolean(true), Id = relationshipId });

            return newParagraph;
        }
开发者ID:shaanino,项目名称:dmt,代码行数:35,代码来源:OpenXmlHelpers.cs

示例8: RefreshCharts

        /// <summary>
        /// Refreshes the charts.
        /// </summary>
        /// <param name="mainDocumentPart">The main document part.</param>
        protected override void RefreshCharts(MainDocumentPart mainDocumentPart)
        {
            if (mainDocumentPart != null)
            {
                foreach (ChartPart chartPart in mainDocumentPart.ChartParts)
                {
                    Chart chart = chartPart.ChartSpace.Elements<Chart>().FirstOrDefault();

                    if (chart != null)
                    {
                        DocumentFormat.OpenXml.Drawing.Charts.ScatterChart scatterChart = chart.Descendants<DocumentFormat.OpenXml.Drawing.Charts.ScatterChart>().FirstOrDefault();
                        DocumentFormat.OpenXml.Drawing.Charts.Line3DChart lineChart = chart.Descendants<DocumentFormat.OpenXml.Drawing.Charts.Line3DChart>().FirstOrDefault();

                        if (scatterChart != null)
                        {
                            ScatterChartEx chartEx = new ScatterChartEx(chartPart, this.scatterChartData);
                            chartEx.Refresh();
                        }

                        if (lineChart != null)
                        {
                            Line3DChartEx chartEx = new Line3DChartEx(chartPart, this.lineChartData);
                            chartEx.Refresh();
                        }
                    }

                    chartPart.ChartSpace.Save();
                }
            }
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:34,代码来源:SampleDocumentWithTableAndChartsGenerator.cs

示例9: InsertAfter

        public override void InsertAfter(OpenXmlElement openXmlNode, MainDocumentPart mainDocumentPart)
        {
            _mainDocumentPart = mainDocumentPart;

            var imagePart = CreateImagePart();
            openXmlNode.InsertAfterSelf(CreateImageElement(mainDocumentPart.GetIdOfPart(imagePart), Path.GetFileName(_content)));
        }
开发者ID:Geaz,项目名称:SharpDox.Plugins.Word,代码行数:7,代码来源:Image.cs

示例10: CreateStyles

 public static Styles CreateStyles(MainDocumentPart mainPart)
 {
     StyleDefinitionsPart styleDefinitionsPart = mainPart.AddNewPart<StyleDefinitionsPart>();
     Styles styles = new Styles();
     styleDefinitionsPart.Styles = styles;
     //styles.Save();
     return styles;
 }
开发者ID:labeuze,项目名称:source,代码行数:8,代码来源:Test_OpenXml_Creator.cs

示例11: OpenTheDocuemnt

        /// <summary>
        /// Open an Word XML document 
        /// </summary>
        /// <param name="docname">name of the document to be opened</param>
        public void OpenTheDocuemnt(string docname)
        {
            // open the word docx
            wordProcessingDocument = WordprocessingDocument.Open(docname, true);

            // get the Main Document part
            mainDocPart = wordProcessingDocument.MainDocumentPart;
        }
开发者ID:veraveramanolo,项目名称:power-show,代码行数:12,代码来源:WordImageUpdateMananger.cs

示例12: AppendTo

        public override void AppendTo(OpenXmlElement openXmlNode, MainDocumentPart mainDocumentPart)
        {
            var text = _newParagraph 
                ? (OpenXmlElement)new Paragraph(new Run(new Text(_content)))
                : (OpenXmlElement)new Run(new Text(_content));

            openXmlNode.Append(text);
        }
开发者ID:Geaz,项目名称:SharpDox.Plugins.Word,代码行数:8,代码来源:PlainText.cs

示例13: CreateDocument

 internal WordprocessingDocument CreateDocument(String fileName)
 {
     docxFile = WordprocessingDocument.Create(fileName, WordprocessingDocumentType.Document);
     mainPart = docxFile.AddMainDocumentPart();
     docxFile.MainDocumentPart.Document = new DocumentFormat.OpenXml.Wordprocessing.Document(new Body());
     body = docxFile.MainDocumentPart.Document.Body;
     return docxFile;
 }
开发者ID:amilasurendra,项目名称:pdf-generator,代码行数:8,代码来源:DocumentPackager.cs

示例14: AppendTo

 public override void AppendTo(OpenXmlElement openXmlNode, MainDocumentPart mainDocumentPart)
 {
     var paragraphs = ConvertContentToParagraphs(mainDocumentPart);
     foreach (var paragraph in paragraphs)
     {
         openXmlNode.Append(paragraph);
     }
 }
开发者ID:Geaz,项目名称:SharpDox.Plugins.Word,代码行数:8,代码来源:RichText.cs

示例15: HtmlDocumentStyle

 internal HtmlDocumentStyle(MainDocumentPart mainPart)
 {
     PrepareStyles(mainPart);
     tableStyle = new TableStyleCollection(this);
     runStyle = new RunStyleCollection(this);
     paraStyle = new ParagraphStyleCollection(this);
     this.QuoteCharacters = QuoteChars.IE;
     this.mainPart = mainPart;
 }
开发者ID:rexyanglucky,项目名称:uba,代码行数:9,代码来源:HtmlDocumentStyle.cs


注:本文中的DocumentFormat.OpenXml.Packaging.MainDocumentPart类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。