wordprocessingml

How to highlight text in a sentence using OpenXML?

断了今生、忘了曾经 提交于 2019-12-11 06:12:01
问题 I am using below code to search and highlight text in a MS Word document, it works fine for point 1 but not point 2: 1. John Alter I search for Alter or John , it highlights John / Alter - works. 2. I am going to school I search for going , it highlights going but it changes its order as I am to school going - does not work. How to fix point 2? Below is my code. private void HighLightText(Paragraph paragraph, string text) { string textOfRun = string.Empty; var runCollection = paragraph

Get a CheckBox in Word using OpenXML

大城市里の小女人 提交于 2019-12-08 23:29:15
问题 How does one get a handle to a CheckBox control that's embedded in a Word document using OpenXML? You would think that either Paragraph.ControlPropertiesPart or Paragraph.Descendents() would achieve something but in every single case I get a null type returned. I can traverse down the document tree using the actual XML structure, but this seems cumbersome. Suggestions welcome. 回答1: The code below shows how to enumerate all checkboxes in a word document by using the Decendants<CheckBox>()

I am merging two Word documents with OpenXML SDK but get a corrupt document when copying an image into a header

好久不见. 提交于 2019-12-06 15:56:28
I have code which works in all sorts of different situations, including when copying images into the body of the document. The code works when copying (adding) headers and footers from one document to the other, as long as the headers/footers being copied do not contain images. When I copy a header which has an image in it, then the resulting file is corrupt, and when I try to open it with the OpenXML SDK it throws an exception saying "Compressed part has inconsistent data length". I do know that the image has to be created in the HeaderPart (as against the MainDocumentPart when copying into

How to grab text from word (docx) document in C#?

家住魔仙堡 提交于 2019-12-06 08:51:22
问题 I'm trying to get the plain text from a word document. Specifically, the xpath is giving me trouble. How do you select the tags? Here's the code I have. public static string TextDump(Package package) { StringBuilder builder = new StringBuilder(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(package.GetPart(new Uri("/word/document.xml", UriKind.Relative)).GetStream()); foreach (XmlNode node in xmlDoc.SelectNodes("/descendant::w:t")) { builder.AppendLine(node.InnerText); } return builder

How can I query a Word docx in an ASP.NET app?

时间秒杀一切 提交于 2019-12-04 23:45:22
问题 I would like to upload a Word 2007 or greater docx file to my web server and convert the table of contents to a simple xml structure. Doing this on the desktop with traditional VBA seems like it would have been easy. Looking at the WordprocessingML XML data used to create the docx file is confusing. Is there a way (without COM) to navigate the document in more of an object-oriented fashion? 回答1: I highly recommend looking into the Open XML SDK 2.0. It's a CTP, but I've found it extremely

Prevent Word 2010 from saving o:gfxdata base64 or uuencoded VML?

时光毁灭记忆、已成空白 提交于 2019-12-04 13:36:15
I am working with .docx files containing several drawing canvases with images inserted and some lines and arrows drawn in Word 2010. I am using 2010 format with no compatibility mode. Word inserts an o:gfxdata attribute into each v:shape and v:group element and fills it with ascii encoded something. From what I have read it may be a copy of the VML describing the v:shape or v:group . I don't know if I just don't know what to look for, but I cannot determine what this data is for as its removal has no apparent effect on my ability to read or edit the document in Word 2003, 2007, or 2010. It

Creating a Word document in Coldfusion - how to have pagenumbering?

瘦欲@ 提交于 2019-12-01 16:53:36
I am creating a Word format .doc using the following code, then cfheader and cfcontent to serve. All is good but I need to be able to place dynamic information in the header (or footer), or automatic pagenumbering would be a second best option. How should I modify the code? <cfsavecontent variable="myDocument"> <html xmlns:w="urn:schemas-microsoft-com:office:word"> <!--- Head tag instructs Word to start up a certain way, specifically in print view. ---> <head> <xml> <w:WordDocument> <w:View>Print</w:View> <w:SpellingState>Clean</w:SpellingState> <w:GrammarState>Clean</w:GrammarState> <w

Creating a Word document in Coldfusion - how to have pagenumbering?

谁都会走 提交于 2019-12-01 15:29:51
问题 I am creating a Word format .doc using the following code, then cfheader and cfcontent to serve. All is good but I need to be able to place dynamic information in the header (or footer), or automatic pagenumbering would be a second best option. How should I modify the code? <cfsavecontent variable="myDocument"> <html xmlns:w="urn:schemas-microsoft-com:office:word"> <!--- Head tag instructs Word to start up a certain way, specifically in print view. ---> <head> <xml> <w:WordDocument> <w:View

Get a CheckBox in Word using OpenXML

荒凉一梦 提交于 2019-11-30 09:24:55
How does one get a handle to a CheckBox control that's embedded in a Word document using OpenXML? You would think that either Paragraph.ControlPropertiesPart or Paragraph.Descendents() would achieve something but in every single case I get a null type returned. I can traverse down the document tree using the actual XML structure, but this seems cumbersome. Suggestions welcome. The code below shows how to enumerate all checkboxes in a word document by using the Decendants<CheckBox>() method on the docuement's body. using (WordprocessingDocument doc = WordprocessingDocument.Open("c:\\temp\