Questions tagged [openxml-sdk]

The Open XML SDK for Microsoft Office is built on top of the System.IO.Packaging API and provides strongly typed part classes to manipulate Open XML documents.

Open XML is an open ECMA 376 standard and is also approved as the ISO/IEC 29500 standard that defines a set of XML schemas for representing spreadsheets, charts, presentations, and word processing documents. Microsoft Office Word 2007, Excel 2007, and PowerPoint 2007 and later versions all use Open XML as the default file format.

The Open XML file formats are useful for developers because they use an open standard and are based on well-known technologies: ZIP and XML.

The Open XML SDK for Microsoft Office is built on top of the System.IO.Packaging API and provides strongly typed part classes to manipulate Open XML documents. (Use version 2.5 whenever possible as it fixes some problems in version 2.0.) The SDK also uses the .NET Framework Language-Integrated Query (LINQ) technology to provide strongly typed object access to the XML content inside the parts of Open XML documents.

The Open XML SDK simplifies the task of manipulating Open XML packages and the underlying Open XML schema elements within a package. The Open XML Application Programming Interface (API) encapsulates many common tasks that developers perform on Open XML packages, so you can perform complex operations with just a few lines of code.

Above is taken from the Overview section here.

In 2015 the Open XML SDK was made open source, public on GitHub. Version 2.6.0 was released which fixes a bug in the way it works with System.IO.Packaging. It is otherwise the same as 2.5. More details are available here.

1516 questions
17
votes
2 answers

Generate a Word document (docx) using data from an XML file / Convert XML to a Word document based on a template

I have an XML file with the data that I need to be populated on a Word document. I need to find a way, to define a template which can be used as a base line to populate data from an XML file and create an output document. I believe there are two…
slayernoah
  • 4,382
  • 11
  • 42
  • 73
17
votes
5 answers

Beginner sample codes for the Open XML SDK?

I recently started working on the Open XML SDK 2.0. I would like to know if there is any better documentation (instead of open xml sdk2.0 itself) or any other resource to learn working with the Open XML SDK?
stazera
  • 293
  • 1
  • 3
  • 9
17
votes
3 answers

Add Header and Footer to an existing empty word document with OpenXML SDK 2.0

I'm trying to add a Header and Footer to an empty word document. I use this code to add Header part in word/document.xml when change docx to zip. ApplyHeader(doc); public static void ApplyHeader(WordprocessingDocument doc) { …
Aelios
  • 11,849
  • 2
  • 36
  • 54
16
votes
2 answers

How to get cell value with applied formatting (formatted cell value) with OpenXML SDK

I've been googling and searching on the site for the answer, but I couldn't find a solution - everywhere people mostly discuss how to add new number format to the document and apply it. What I need is to get the cell value as a string with applied…
El G
  • 163
  • 1
  • 1
  • 6
16
votes
6 answers

openxml spreadsheat save-as

I have an Excel 2007 spreadsheet that I edit with the OpenXML SDK 2. I remove some rows etc. I would like to know how to save that Spreadsheetdocument to another filename.
jwdehaan
  • 1,445
  • 3
  • 13
  • 25
15
votes
1 answer

Create Merge Cells using OpenXML

Please consider this Excel: and it's XML: I want to create such this Excel that has multiple merged cells using OpenXML. How I can do this? thanks
Arian
  • 12,793
  • 66
  • 176
  • 300
15
votes
3 answers

Replacing Content Controls in OpenXML

I need something as a placeholder. I at first looked to Content Control as a solution but I'm having some problems with it. I then looked into adding CustomXML to the .docx but turned away from that because of the i4i lawsuit. Then I decided I would…
Ingó Vals
  • 4,788
  • 14
  • 65
  • 113
15
votes
3 answers

create word document with Open XML

I am creating a sample handler to generate simple Word document. This document will contains the text Hello world This is the code I use (C# .NET 3.5), I got the Word document created but there is no text in it, the size is 0. How can I fix it? (I…
Tuyen Nguyen
  • 4,389
  • 7
  • 51
  • 77
15
votes
2 answers

OpenXML SDK having borders for cell

I have the following code that adds a cell with values and data-type for that cell in OpenXML SDK: Cell cell = InsertCellInWorksheet(column, row, worksheetPart); cell.CellValue = new CellValue(index.ToString()); cell.DataType = new…
Nate Pet
  • 44,246
  • 124
  • 269
  • 414
14
votes
2 answers

OpenXML add new row to existing Excel file

I've got lots of XLSX files and I need to append a new row after the last one in the file. I'm using OpenXML and so far I know how to open/create spreadsheet, but my search for adding new rows to existing files returned nothing. Any ideas ?
james
  • 165
  • 1
  • 1
  • 6
14
votes
6 answers

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…
chiccodoro
  • 14,407
  • 19
  • 87
  • 130
14
votes
1 answer

Shared Strings in Excel 2010

Can someone help me in understanding the Shared Strings in MS Excel? I tried to understand using some blogs but could not get complete idea. Everyone is explaining how to access Shared String using Open XML and where the Shared Strings stored (as…
Santhosh
  • 1,357
  • 4
  • 15
  • 30
13
votes
4 answers

Reading .Doc File using DocumentFormat.OpenXml dll

When I am trying to read .doc file using DocumentFormat.OpenXml dll its giving error as "File contains corrupted data." This dll is reading .docx file properly. Can DocumentFormat.OpenXml dll help in reading .doc file? string path =…
Shardaprasad Soni
  • 541
  • 2
  • 6
  • 10
13
votes
4 answers

Excel and "unreadable content" when creating an Open XML spreadsheet with MemoryStream

When creating an Excel spreadsheet using the Open XML SDK v2.0, our Excel output initially worked successfully for a number of months. Recently Excel (all versions) began to complain about "Excel found unreadable content in 'zot.xlsx'. Do you want…
energyiq
  • 141
  • 1
  • 5
13
votes
2 answers

How To make some text bold in cell using OpenXml

i have try to make bold the specific text using Bold fbld = new Bold(); but it will make bold hall cell. Here in above image there is some bold text into the cell. How can I do this in OpenXml using C#?
Divyesh
  • 438
  • 1
  • 4
  • 13