Save modified WordprocessingDocument to new file

If you use a MemoryStream you can save the changes to a new file like this: byte[] byteArray = File.ReadAllBytes(“c:\\data\\hello.docx”); using (MemoryStream stream = new MemoryStream()) { stream.Write(byteArray, 0, (int)byteArray.Length); using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(stream, true)) { // Do work here } // Save the file with the new name File.WriteAllBytes(“C:\\data\\newFileName.docx”, stream.ToArray()); }

How to export a JQgrid data to Excel using c#?

The code which I posted in the answer can be used practically without any modification in any ASP.NET code which are written in C#. The helper class DataForExcel (see the file DataForExcel.cs) has constructor public DataForExcel(string[] headers, List<string[]> data, string sheetName) or a little more “advanced” version public DataForExcel(string[] headers, DataType[] colunmTypes, List<string[]> data, string … Read more

OpenXML tag search

The problem with trying to find tags is that words are not always in the underlying XML in the format that they appear to be in Word. For example, in your sample XML the <!TAG1!> tag is split across multiple runs like this: <w:r> <w:rPr> <w:lang w:val=”en-GB”/> </w:rPr> <w:t>&lt;!TAG1</w:t> </w:r> <w:proofErr w:type=”gramEnd”/> <w:r> <w:rPr> <w:lang … Read more