How to include the reference of DocumentFormat.OpenXml.dll on Mono2.10?

Being new to this myself, here’s what I did: I’m using MS Visual Studio 2010 Pro. Download and install the OpenXML SDK Within my project in Visual Studio, select “Project” then “Add Reference” Select the “Browse” tab In the “Look in:” pull down, navigate to: C:\Program Files(x86)\Open XML SDK\V2.0\lib and select the “DocumentFormat.OpenXml.dll Hit OK … Read more

open xml reading from excel file

Your approach seemed to work ok for me – in that it did “enter the loop”. Nevertheless you could also try something like the following: void Main() { string fileName = @”c:\path\to\my\file.xlsx”; using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (SpreadsheetDocument doc = SpreadsheetDocument.Open(fs, false)) { WorkbookPart workbookPart = doc.WorkbookPart; SharedStringTablePart sstpart … Read more

Create page break using OpenXml

You can create a page break within a Run element using the <w:br> element. In raw OpenXML, it would look something like: <w:p> <w:r> <w:br w:type=”page” /> </w:r> </w:p> If you’re using the OpenXml SDK, you can use new Paragraph( new Run( new Break(){ Type = BreakValues.Page })); EDIT: If you just want to specify … Read more

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()); }