openxml-sdk

How to Add Serialized LINQ to SQL Entities to a Word 2007 Document

I built a template-based document generator using the Open XML SDK (1.0), the Word 2007 Content Control Toolkit and LINQ to SQL (using the CodeSmith PLINQO templates). To do this, I serialized the LINQ to SQL entities to XML by retrieving the entity using DataLoadOptions specified in the source code. This works great, except that to ini...

Word 2007 Master Pages

I'm using the Open XML SDK to work with Word 2007 templates, and the project continues to progress nicely. Now I would like to add consistent headers and footers to every document, very similar to an ASP.NET MasterPage. In particular, I'd like to compose a template document with a content document, then fill the content using the approac...

Union with LINQ to XML

I need to union two sets of XElements into a single, unique set of elements. Using the .Union() extension method, I just get a "union all" instead of a union. Am I missing something? var elements = xDocument.Descendants(w + "sdt") .Union(otherDocument.Descendants(w + "sdt") .Select(sdt => ...

OpenXML SDK Spreadsheet starter kits

I am trying to start working with excel documents through the OpenXML SDK Spreadsheet API. But I havent found any good guides or even examples on how to create a xlsx file from scratch. Only how to open an existing document and modify it. I have been thinking on having a empty template document and make a copy of it an then begin my pro...

Inserting a string array as a row into an Excel document using the Open XML SDK 2.0

The code runs, but corrupts my excel document. Any help would be mucho appreciated! I used this as a reference. public void AddRow(string fileName, string[] values) { using (SpreadsheetDocument doc = SpreadsheetDocument.Open(fileName, true)) { SharedStringTablePart sharedStringPart = ...

XLSX- how to get rid of the default namespace prefix x: ?

I'm generating XLSX spreadsheet using OOXML SDK, and I need to get rid of x: namespace prefix. How can I achieve this? using (SpreadsheetDocument doc = SpreadsheetDocument.Open("template.xlsx", true)) { //Save the shared string table part if (doc.WorkbookPart.GetPartsOfType().Count() > 0) ...

Word OpenXML . Traversing OpenXmlElements between bookmarks.

I need to traverse nodes between a bookmark start and a bookmark end tag. The problem appears to break down into a tree traversal but I am having trouble pinning down the correct algorithm. The bookmark start and end elements are non-composite nodes (no children) and may appear at an arbitrary depth in the tree. Bookmark start are als...

How to add content control in a word 2007 document using open xml

Hi I want to create a word 2007 document without using object model. So I would prefer to create it using open xml format. So far I have been able to create the document. Now I want to add a content control in it and map it to xml. Can anybody guide me regarding the same??? ...

Open XML SDK v2.0 Performance issue when deleting a first row in 20,000+ rows Excel file

Do anyone come across a performance issue when deleting a first row in a 20,000+ rows Excel file using OpenXML SDK v2.0? I am using the delete row coding suggested in the Open XML SDK document. It takes me several minutes just to delete the first row using Open XML SDK, but it only takes just a second in Excel applicaton. I eventually ...

.NET OpenXML SDK 2 RunProperties are Null

Hello, I'm trying to read Word 2007 docx document. The document looks fine inside Word, but when i try to read id using my code, all Run objects have RunProperites set null. The property that I'm most interested in is RunProperies.FontSize, but unfortunately it is null as well, the only property I can access is InnerText. My Code l...

Comparing Docx files using OOXML

How can I read word-by-word (with styles) from a docx file. I want to compare two docx files word-by-word and based on the differences I have to write into another docx file (using c# and OOXML). I have tried achieving this by using DocumentFormat.OpenXml.Extensions.dll, OpenXMLdiff.dll and ICSharpCode.SharpZipLib.dll but nothing is givi...

Binding CustomXml to Headerpart

Hi I am at my whits-end with this problem. I can successful bind xml to the main document part, however I cannot seem to be able to get content controls in the header to bind to the xml. AddCustomXmlPart doesn't seem to exist for Headerpart and if I try to add a CustomXmlPart via hdrpart.AddPart(xmlPart); I get an Invalid operation ...

Merge documents

I'm trying to merge two docx-documents into one docx-document using OpenXML SDK 2.0. The documents should be merged without loosing their styling and custom headers and footers. I hope I can achieve this using AltChunk and a section break. But I can't get it working. Is it possible what I'm trying to do? Can someone give me a hint how t...

How do I add a new sheet to an Excel .xlsx file using the OpenXML SDK v2.0 with c#?

Just posting the solution I worked out today. See my answer below. If you don't have the very helpful OpenXML SDK v2.0 Tool, you can find it at http://www.microsoft.com/downloads/details.aspx?FamilyID=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en If you know the purpose of the lines I commented with "I don't know...", please...

Save PowerPoint 2007 as PowerPoint 2003 using Open Office SDK 2.0

Is there anyway to use the Open Office SDK 2.0 to save a PowerPoint presention that you created using OOXML to a PowerPoint 2003 presentation? I know if you open a 2007 file and click Save As you have the option to save it as a PowerPoint 97 to 2003 document and I didn't know if I could do this grammatically using this SDK. The reaso...

Exporting dataset to Excel file with multiple sheets in ASP.NET

In C# ASP.NET 3.5 web application, I need to export multiple datatables (or a dataset) to an Excel 2007 file with multiple sheets, and then provide the user with 'Open/Save' dialog box, WITHOUT saving the Excel file on the web server. I have used Excel Interop before. I have been reading that it's not efficient and is not the best appro...

Use SSIS to populate Excel workbook generated using OOXML

We are trying to generate MS Excel workbook using OOXML and populate data using SSIS. We are able to generate Workbook and sheets, also able to create columns and insert data in the Header cell. We can also populate data using SSIS. But the Sheet (DocumentFormat.OpenXml.Spreadsheet.Sheet) and all cells (DocumentFormat.OpenXml.Spreadshee...

How to split table to new PowerPoint slide when content flows off current slide using Open XML SDK 2.0

I have a bunch of data that I need to export from a website to a PowerPoint presentation and have been using Open XML SDK 2.0 to perform this task. I have a PowerPoint presentation that I am putting through Open XML SDK 2.0 Productivity Tool to generate the template code that I can use to recreate the export. On one of those slides I...

How to create a Word document from a Silverlight 4 application?

I'm looking for some options to programmatically create a Word document from within a Silverlight 4 application. I found two approaches which seemed promising at first but don't look like they will work. OpenXML SDK The OpenXML SDK isn't available for Silverlight at this time. Word Automation via COM Interop dynamic wordApplication =...

OpenXML SDK: Make Excel recalculate formula

I update some cells of an Excel spreadsheet through the Microsoft Office OpenXML SDK 2.0. Changing the values makes all cells containing formula that depend on the changed cells invalid. However, due to the cached values Excel does not recalculate the formular, even if the user clicks on "Calculate now". What is the best way to invalida...