openxml-sdk 相关问题

Open XML SDK for Microsoft Office构建于System.IO.Packaging API之上,并提供强类型的零件类来操作Open XML文档。

NoTextEdit ShapeLock不起作用-OpenXML SDK

我正在尝试通过使用OpenXML SDK锁定TextBox。我已经尝试过这种方法,但是TextBox NoTextEdit无法正常工作。 public DocumentFormat.OpenXml.Presentation.Shape GenerateShape(string ...

回答 1 投票 1

在PowerPoint OpenXml C#中访问特定的TextBody

我正在尝试从PowerPoint模板中的特定文本框中提取文本,以使用OpenXml和C#填充Web表单。到目前为止,我在网上看到的内容都使用Slide遍历了所有文本框。...

回答 1 投票 0

样式格式Openxml

我正在尝试使用Openxml构建文档,当我向styles.xml中添加样式并尝试对其进行验证时,出现以下错误,该元素具有意外的子元素'http:// schemas ....] >

回答 1 投票 0

如何使用OpenXML SDK在Powerpoint幻灯片中隐藏文本?

我正在尝试使用OpenXML SDK在幻灯片(或TextBox)中隐藏文本。如何在用户看不到的情况下隐藏文本?我尝试使用Drawing.Run方法设置不透明度,但它没有...

回答 1 投票 1

如何在Open XML中放大子弹?

我正在使用.NET的Open XML SDK生成docx文件。列表中的项目符号非常小,但我不知道为什么。所以,这就是我要做的事情:生成带有单个项目符号项的文档...

回答 1 投票 0

使用c#使用Open xml替换单词表中的令牌

我有一个要求,我要根据计数将单词表克隆到多个表中并插入到Word文档中。如果我有5条记录,则应使用现有的表克隆和...

回答 1 投票 0

如何使用openxml合并具有不同标题的word文档?

我正在尝试按照另一篇文章中的示例将多个文档合并为一个文档。我正在使用AltChunk altChunk =新的AltChunk()。合并文档时,似乎没有...

回答 1 投票 0

是在OpenXml C#中并排放置两个段落的方法吗?

我正在尝试创建一个如下所示的OpenXml Word文档:2.1.1这是2.1.2段落这也是2.1.2.1段落此段落与2.1.2有关。最初的计划是...

回答 1 投票 0

Word打开文件时发现不可读的内容错误

我遇到错误“ Word在abc.docx中发现了不可读的内容。您要恢复此文档的内容吗?”同时打开Word(.docx)文件。我已经尝试了所有给定的解决方案...

回答 1 投票 0

获取节点上可能包含的元素列表

我在验证我的XML时遇到错误:“该元素具有意外的子元素'http://schemas.openxmlformats.org/drawingml/2006/main:p'。预期的可能元素列表:http://模式....

回答 1 投票 0

如何使用openxml在ASP.NET MVC项目中打开docx文件来覆盖某些文本

我已经搜索了很多解决方案,但找不到任何解决方案。我的MVC项目文件夹中有一个.docx文件,我想打开该文件以覆盖一些文本,但是我无法这样做。在我的项目中...

回答 1 投票 1

如何使用OpenXML SDK在Excel中附加.eml文件?

我正在使用此代码。它确实附加了文件,但是如果使用MS Excel应用程序打开文件,我什么也看不到。字符串targetFile =“测试返回tracker.xlsx”;字符串...

回答 1 投票 0



是否可以使用C#和Open XML SDK在Word文档中显示多级列表? [关闭]

我需要使用Word文档中的多级列表来设置文本格式(例如,标题,带编号的段落)。这应该使用Open XML SDK在C#中实现。这是必需的示例...

回答 1 投票 -1

从'WordOpenXML'转换为In-Memory System.IO.Packaging.Package

[使用VSTO 2012操作MS Word文档时,我看到该文档具有WordOpenXML字符串属性,该属性是构成.docx包的所有文件的XML表示,......]

回答 1 投票 2

使用OpenXml API更新Word Customxml部件,但无法更新主文档中的“ document.xml”

我们使用C#代码更新自定义xml部分。我们已成功更新寡妇中的文档。但是我们可以在Linux环境中打开此文档,不能更改它的值。如何实现...

回答 1 投票 -1

如何通过C#通过OpenXML从Word(.Docx)提取OLE文件

我想使用Openxml从“ .docx”文件中提取“ OLE包”。我不知道该怎么做,在官方示例中也找不到任何示例。请帮我。这是我的尝试:1.I ...

回答 1 投票 0

OpenXML DataBinding不适用于名称空间

我有一个Word文档,其中包含一个内容控件XML。这是来自document.xml的内容控件的代码: [[[[]]]] 下面的单元测试表明,只有在使用命名空间前缀(例如“ ex”)的情况下,您才能将w:sdt元素绑定到具有XML命名空间(例如“ http://example.com”)的自定义XML元素。 )放在w:prefixMappings元素的w:xpath和w:dataBinding属性中。 不过,您的自定义XML元素不需要名称空间前缀。因此,以下两个XML文档都将起作用: <?xml version="1.0" encoding="utf-8"?> <ex:Root xmlns:ex="http://example.com"> <ex:Node>VALUE1</ex:Node> </ex:Root> <?xml version="1.0" encoding="utf-8"?> <Root xmlns="http://example.com"> <Node>VALUE1</Node> </Root> 这里是单元测试: using System; using System.Xml.Linq; using DocumentFormat.OpenXml; using DocumentFormat.OpenXml.CustomXmlDataProperties; using DocumentFormat.OpenXml.Packaging; using OpenXmlPowerTools; using Xunit; namespace CodeSnippets.Tests.OpenXml.Wordprocessing { public class DataBoundContentControlTests { private const WordprocessingDocumentType Type = WordprocessingDocumentType.Document; private const string NsPrefix = "ex"; private const string NsName = "http://example.com"; private static readonly XNamespace Ns = NsName; private static string CreateCustomXmlPart(MainDocumentPart mainDocumentPart, XElement rootElement) { CustomXmlPart customXmlPart = mainDocumentPart.AddCustomXmlPart(CustomXmlPartType.CustomXml); customXmlPart.PutXDocument(new XDocument(rootElement)); return CreateCustomXmlPropertiesPart(customXmlPart); } private static string CreateCustomXmlPropertiesPart(CustomXmlPart customXmlPart) { XElement rootElement = customXmlPart.GetXElement(); if (rootElement == null) throw new InvalidOperationException(); string storeItemId = "{" + Guid.NewGuid().ToString().ToUpper() + "}"; // Create a ds:dataStoreItem associated with the custom XML part's root element. var dataStoreItem = new DataStoreItem { ItemId = storeItemId, SchemaReferences = new SchemaReferences() }; if (rootElement.Name.Namespace != XNamespace.None) { dataStoreItem.SchemaReferences.AppendChild(new SchemaReference {Uri = rootElement.Name.NamespaceName}); } // Create the custom XML properties part. var propertiesPart = customXmlPart.AddNewPart<CustomXmlPropertiesPart>(); propertiesPart.DataStoreItem = dataStoreItem; propertiesPart.DataStoreItem.Save(); return storeItemId; } [Fact] public void CanDataBindBlockLevelSdtToCustomXmlWithNsPrefixIfNsPrefixInPrefixMapping() { // The following root element has an explicitly created attribute // xmlns:ex="http://example.com": // // <ex:Root xmlns:ex="http://example.com"> // <ex:Node>VALUE1</ex:Node> // </ex:Root> // var customXmlRootElement = new XElement(Ns + "Root", new XAttribute(XNamespace.Xmlns + NsPrefix, NsName), new XElement(Ns + "Node", "VALUE1")); using WordprocessingDocument wordDocument = WordprocessingDocument.Create("SdtBlock_NsPrefix_WithNsPrefixInMapping.docx", Type); MainDocumentPart mainDocumentPart = wordDocument.AddMainDocumentPart(); string storeItemId = CreateCustomXmlPart(mainDocumentPart, customXmlRootElement); mainDocumentPart.PutXDocument(new XDocument( new XElement(W.document, new XAttribute(XNamespace.Xmlns + "w", W.w.NamespaceName), new XElement(W.body, new XElement(W.sdt, new XElement(W.sdtPr, new XElement(W.dataBinding, // Note the w:prefixMapping attribute WITH a namespace // prefix and the corresponding w:xpath atttibute. new XAttribute(W.prefixMappings, $"xmlns:{NsPrefix}='{NsName}'"), new XAttribute(W.xpath, $"{NsPrefix}:Root[1]/{NsPrefix}:Node[1]"), new XAttribute(W.storeItemID, storeItemId))), new XElement(W.sdtContent, new XElement(W.p))))))); // Note that we just added an empty w:p to the w:sdtContent element. // However, if you open the Word document created by the above code // in Microsoft Word, you should see a single paragraph saying // "VALUE1". } [Fact] public void CanDataBindBlockLevelSdtToCustomXmlWithoutNsPrefixIfNsPrefixInPrefixMapping() { // The following root element has an implicitly created attribute // xmlns='http://example.com': // // <Root xmlns="http://example.com"> // <Node>VALUE1</Node> // </Root> // var customXmlRootElement = new XElement(Ns + "Root", new XElement(Ns + "Node", "VALUE1")); using WordprocessingDocument wordDocument = WordprocessingDocument.Create("SdtBlock_DefaultNs_WithNsPrefixInMapping.docx", Type); MainDocumentPart mainDocumentPart = wordDocument.AddMainDocumentPart(); string storeItemId = CreateCustomXmlPart(mainDocumentPart, customXmlRootElement); mainDocumentPart.PutXDocument(new XDocument( new XElement(W.document, new XAttribute(XNamespace.Xmlns + "w", W.w.NamespaceName), new XElement(W.body, new XElement(W.sdt, new XElement(W.sdtPr, new XElement(W.dataBinding, // Note the w:prefixMapping attribute WITH a namespace // prefix and the corresponding w:xpath atttibute. new XAttribute(W.prefixMappings, $"xmlns:{NsPrefix}='{NsName}'"), new XAttribute(W.xpath, $"{NsPrefix}:Root[1]/{NsPrefix}:Node[1]"), new XAttribute(W.storeItemID, storeItemId))), new XElement(W.sdtContent, new XElement(W.p))))))); // Note that we just added an empty w:p to the w:sdtContent element. // However, if you open the Word document created by the above code // in Microsoft Word, you should see a single paragraph saying // "VALUE1". } [Fact] public void CannotDataBindBlockLevelSdtToCustomXmlWithDefaultNsIfNotNsPrefixInPrefixMapping() { // The following root element has an implicitly created attribute // xmlns='http://example.com': // // <Root xmlns="http://example.com"> // <Node>VALUE1</Node> // </Root> // var customXmlRootElement = new XElement(Ns + "Root", new XElement(Ns + "Node", "VALUE1")); using WordprocessingDocument wordDocument = WordprocessingDocument.Create("SdtBlock_DefaultNs_WithoutNsPrefixInMapping.docx", Type); MainDocumentPart mainDocumentPart = wordDocument.AddMainDocumentPart(); string storeItemId = CreateCustomXmlPart(mainDocumentPart, customXmlRootElement); mainDocumentPart.PutXDocument(new XDocument( new XElement(W.document, new XAttribute(XNamespace.Xmlns + "w", W.w.NamespaceName), new XElement(W.body, new XElement(W.sdt, new XElement(W.sdtPr, new XElement(W.dataBinding, // Note the w:prefixMapping attribute WITHOUT a namespace // prefix and the corresponding w:xpath atttibute. new XAttribute(W.prefixMappings, $"xmlns='{NsName}'"), new XAttribute(W.xpath, "Root[1]/Node[1]"), new XAttribute(W.storeItemID, storeItemId))), new XElement(W.sdtContent, new XElement(W.p))))))); // Note that we just added an empty w:p to the w:sdtContent element. // If you open the Word document created by the above code in Microsoft // Microsoft Word, you will only see an EMPTY paragraph. } } }

回答 1 投票 0

如何在ASP.net中使用Open XML创建多级有序列表?

我花了无数时间试图理解Open XML中的有序列表。这是众多参考文献之一。我在这里找到了一个简单的文档创建者的非常有用的示例。另外,如果我可以...

回答 1 投票 2

© www.soinside.com 2019 - 2024. All rights reserved.