• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Packaging.MainDocumentPart类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: InsertAfter

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


示例17: HtmlConverter

 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="mainPart">The mainDocumentPart of a document where to write the conversion to.</param>
 /// <remarks>We preload some configuration from inside the document such as style, bookmarks,...</remarks>
 public HtmlConverter(MainDocumentPart mainPart)
 {
     this.mainPart = mainPart;
     this.RenderPreAsTable = true;
     this.ImageProcessing = ImageProcessing.AutomaticDownload;
     this.knownTags = InitKnownTags();
     this.htmlStyles = new HtmlDocumentStyle(mainPart);
     this.knownImageParts = new Dictionary<Uri, CachedImagePart>();
     this.WebProxy = new WebProxy();
 }
开发者ID:TimNFL,项目名称:PEACReportsDemo,代码行数:15,代码来源:HtmlConverter.cs


示例18: GetHeaderTextElement

        private OpenXmlElement GetHeaderTextElement(MainDocumentPart mainDocumentPart)
        {
            var paragraph = new Paragraph(new Run(new Text(_content)));
            var styleId = GetStyleIdbyName(mainDocumentPart, string.Format("Heading {0}", _navigationLevel));
            if (!string.IsNullOrEmpty(styleId))
            {
                paragraph.ParagraphProperties = new ParagraphProperties(new ParagraphStyleId() { Val = styleId });
            }

            return paragraph;
        }
开发者ID:Geaz,项目名称:SharpDox.Plugins.Word,代码行数:11,代码来源:HeaderText.cs


示例19: GenerateTextContent

        public void GenerateTextContent(MainDocumentPart mainPart, Client client, string contentFile)
        {
            GetContent(client, contentFile);
            string customXml = File.ReadAllText(destinationXml);
            replaceCustomXML(mainPart, customXml);
            mainPart.Document.Save();

            //Delete the temp files
            //File.Delete(tempFile);
            //File.Delete(destinationXml);
        }
开发者ID:garsiden,项目名称:Report-Generator,代码行数:11,代码来源:TextContent.cs


示例20: RemoveCustomXmlPart

        /// <summary>
        /// Removes the custom XML part.
        /// </summary>
        /// <param name="mainDocumentPart">The main part.</param>
        /// <param name="customXmlPart">The custom XML part.</param>
        public static void RemoveCustomXmlPart(MainDocumentPart mainDocumentPart, CustomXmlPart customXmlPart)
        {
            if (mainDocumentPart == null)
            {
                throw new ArgumentNullException("mainDocumentPart");
            }

            if (customXmlPart != null)
            {
                RemoveCustomXmlParts(mainDocumentPart, new List<CustomXmlPart>(new[] { customXmlPart }));
            }
        }
开发者ID:nagyist,项目名称:BuildManager,代码行数:17,代码来源:CustomXmlPartCore.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Packaging.WorkbookPart类代码示例发布时间:2022-05-24
下一篇:
C# Packaging.ImagePart类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap