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
5
votes
1 answer

How to read values from a table in a word doc using C#

I'm trying to connect to a Microsoft word document (.docx) to read values from tables located in the .docx. I'm using Open-XML SDK 2.0 to make the connection to the .docx file. So far after looking for examples and ideas, I have this, public static…
Ian jackman
  • 57
  • 1
  • 3
5
votes
1 answer

Write to Existing Excel File Using OpenXML

Can anyone please tell me what I am missing in my code? It runs without any errors, but it will not write to my Excel file. I am just trying to get it to write to cell A1 on the Commercial tab of my spreadsheet. My code is below: using…
Josh W
  • 51
  • 1
  • 1
  • 2
5
votes
2 answers

Open XML SDK - Save a template file (.xltx to .xlsx)

I have the following code to open Excel template file and save it as .xlsx file and I get the error below when I try to open the new file. Please help to resolve this. Excel cannot open the file ‘sa123.xlsx’ because the file format or the extension…
SRAMPI
  • 373
  • 8
  • 23
5
votes
1 answer

WordML templating with XML Schema and OpenXML SDK

I'm trying to use a docx read in via the OpenXML SDK as template in a .Net web app for form letters (essentially). I have a docx with the formatting I want, marked up with XML Schema tags defined from a xsd (whatever they're called, the help is…
Matt Sieker
  • 9,349
  • 2
  • 25
  • 43
5
votes
0 answers

Convert altChunk to Paragraph with open xml

I have generated Word/docx document in C# with OpenXML. There was added/merged other one docx document with altChunk. When you open that document it looks great. But further I need to process that document with C# code. Than I saw that there remains…
Rastko
  • 890
  • 1
  • 17
  • 32
5
votes
3 answers

When using MergeField FieldCodes in OpenXml SDK in C# why do field codes disappear or fragment?

I have been working successfully with the C# OpenXml SDK (Unofficial Microsoft Package 2.5 from NuGet) for some time now, but have recently noticed that the following line of code returns different results depending on what mood Microsoft Word…
The Senator
  • 5,181
  • 2
  • 34
  • 49
5
votes
3 answers

Is there a way to fix the width of a column using OpenXml Library in C#?

I have a Word table with 2 columns. I am trying to get Word not to squeeze column1 when column2 has long text that wraps. here is the intended layout: column1 Column2 ------- ------- 1. Long text that…
shakyjake
  • 123
  • 1
  • 9
5
votes
1 answer

How to keep style on open xml documents

I am using open XML(Microsoft Word - .docx) as a file template to automatically generate other documents. In the template document I have defined content controls, and I have written code to replace content in these content controls. The content is…
Ilyas
  • 295
  • 5
  • 19
5
votes
1 answer

How to get all merge fields of word document using open xml sdk

I am beginner to open xml sdk. I am trying to find out all merge fields of document. But I am not getting the headers and footers merge fields. Can any one suggest a working solution? I am trying some thing like this - foreach (FieldCode field in…
5
votes
1 answer

OpenXML get sheet name from Worksheet

I'm iterating over my worksheets like so WorkbookPart wbPart = doc.WorkbookPart; SharedStringTablePart sstPart = wbPart.GetPartsOfType().First(); SharedStringTable sst = sstPart.SharedStringTable; foreach (var wsp in…
rocklobster
  • 609
  • 2
  • 10
  • 23
5
votes
1 answer

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…
amurra
  • 15,221
  • 4
  • 70
  • 87
5
votes
1 answer

OpenXML Create "Table/Pivot Table" Dynamically

I'm creating a sample program that generates an excel on memory. The program already generates the excel, however i can't put the table working... Program: public class Program { static void Main(string[] args) { …
Leandro Soares
  • 2,902
  • 2
  • 27
  • 39
5
votes
1 answer

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…
amurra
  • 15,221
  • 4
  • 70
  • 87
5
votes
2 answers

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…
Jelle
  • 322
  • 3
  • 14
5
votes
1 answer

.NET OpenXML SDK 2 RunProperties are Null

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…
Daniil Harik
  • 4,619
  • 10
  • 55
  • 60