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
9
votes
3 answers

How to insert image into header of OpenXML Word document?

My OpenXML Word document generation project requires text, tables, and images. But first, I need a document header with a logo (image) in it. I've used the Microsoft example for creating headers and footers at Generating Documents with Headers and…
user2595824
  • 91
  • 1
  • 1
  • 3
9
votes
1 answer

How can I get the Worksheetpart from name or sheet ID in OpenXML?

The following creates an XLSX, adds two worksheets with some data. I then want to be able to get the spreadsheet later based on name (or preferably the id) so I can add/modify the sheets at a later point in time. I'm stuck on how to get the sheet…
WhiskerBiscuit
  • 4,795
  • 8
  • 62
  • 100
9
votes
5 answers

OpenXml: Worksheet Child Elements change in ordering results in a corrupt file

I am trying to use openxml to produce automated excel files. One problem I am facing is to accomodate my object model with open xml object model for excel. I have to come to a point where I realise that the order in which I append the child elements…
mariner
  • 930
  • 3
  • 16
  • 25
9
votes
5 answers

.NET OpenXML performance issues

I am attempting to write out an Excel file from an ASP.NET web server using OpenXML. I have about 2100 records and its taking around 20-30 seconds to do this. Any way I can make it faster? Retrieving the 2100 rows from the db takes a fraction of a…
The Internet
  • 7,959
  • 10
  • 54
  • 89
8
votes
4 answers

OpenXML SDK 2.0 vs Aspose for server side word 2007 document generation in .NET

I am going to start a Server side Office automation project in .Net. Below are the key activities that are planned: Create a word document Use a existing word document template having cover page, header, footer, TOC Save file Embed files and resize…
Ajit Singh
  • 1,016
  • 13
  • 26
8
votes
1 answer

Dynamically add image to powerpoint openxml

I am creating power point 2007 files using the openxml. I am able to add slides, shapes, text and manipulate them to create custom reports. However, I can not find an example on how to dynamically load an image into my power points. In principle…
Avitus
  • 15,640
  • 6
  • 43
  • 53
8
votes
1 answer

OpenXml Force image fit in parent container

I'm parsing a piece of hmtl into a word document using the following code //Need the following packages // //
George Vovos
  • 7,563
  • 2
  • 22
  • 45
8
votes
1 answer

What's the difference between and in Office Open XML?

What's the difference between these two Office Open XML fragments? btyler and btyler note: The second sample I created manually based on the spec, the first is from an actual…
Samuel Neff
  • 73,278
  • 17
  • 138
  • 182
8
votes
1 answer

C# OpenXML: Number Format is not applied

I'm trying to format decimal and integer numbers like "1,000.00" in my .xlsx file. The code for generating stylesheet: private Stylesheet GenerateStylesheet() { //styling and formatting var cellFormats = new CellFormats(); uint…
user1016945
  • 877
  • 3
  • 22
  • 38
8
votes
2 answers

Download an excel file and read content with azure functions

I am trying to write a C# Azure Function to download and open an excel file using the OpenXml-SDK. Office Interop doesn't work here because office is not available to the Azure Function. I am trying to use OpenXml-SDK to open and read the file which…
donquijote
  • 1,642
  • 5
  • 19
  • 41
8
votes
1 answer

OpenXML having trouble coloring cells

I am attempting to style cells and I cant get the colors to work correctly, I am using the following Fill: // Fill fill0 = new Fill(); // Default fill Fill fill1 = new Fill( new PatternFill( new ForegroundColor() { Rgb =…
naspinski
  • 34,020
  • 36
  • 111
  • 167
8
votes
1 answer

Open XML SDK - Create docx from template (dotx) using MemoryStream as docx holder

I am trying to create a .docx file from a word template (.dotx), using OpenXML 2.5 library. More exactly, I'm trying to follow this , but I want to open the document using a MemoryStream and not the path to the file. So in the link above, the…
darkdante
  • 707
  • 1
  • 17
  • 36
8
votes
3 answers

Link to Microsoft Open XML SDK tutorials

Anyone know any link to a good Microsoft Open XML tutorials?
Waliaula Makokha
  • 815
  • 1
  • 11
  • 21
8
votes
5 answers

How can I embed any file type into Microsoft Word using OpenXml 2.0

I spent a lot of time trying to figure out a good way to embed any file into Microsoft Word using OpenXml 2.0; Office documents are fairly easy but what about other file types such as PDF, TXT, GIF, JPG, HTML, etc.... What is a good way to get this…
D Lyonnais
  • 323
  • 1
  • 3
  • 9
8
votes
2 answers

Why appending AutoFilter corrupts my excel file in this example?

Hi I use the below method to apply an AutoFilter : public static void ApplyAutofilter(string fileName, string sheetName, string reference) { using (SpreadsheetDocument document = SpreadsheetDocument.Open(fileName, true)) …
pencilCake
  • 51,323
  • 85
  • 226
  • 363