Retrieving data stored in a .docx file using C #

When I run the following code in a .docx file, child2.innerText will print the information I get after (although not separating the text from the individual columns of the table).
My problem is that the innerXml associated with this is completely incomprehensible to me. I thought there would be a get cell from table method or such. I have no idea how to extract columns / rows from the xml that gave me.
I am completely new to C #, so I may miss something obvious. I am using openxml and a .docx file.

using (WordprocessingDocument wdoc = WordprocessingDocument.Open(pathToMiniToktrapport, false)) { var table = wdoc.MainDocumentPart.Document.Body.Elements<Table>(); foreach (var child in table) { foreach (var child2 in child) { System.Console.WriteLine(child2.InnerXml); System.Console.WriteLine(child2.InnerText); System.Console.ReadLine(); } } } 

Thanks!

+4
source share
1 answer

Follow the link on MSDN, which shows a typical structure and sample code.

http://msdn.microsoft.com/en-us/library/office/cc850835.aspx

+2
source

Source: https://habr.com/ru/post/1487919/


All Articles