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

How to insert a shape in a powerpoint slide using OpenXML

This question could seem rather basic, but how do I insert a shape (i. e. a rectangle) in a slide using OpenXML in c#? I've searched around and all I see is "create a slide with the shape and use the SDK Productivity Tool to reflect the code. That's…
Yván Ecarri
  • 1,661
  • 18
  • 39
12
votes
2 answers

OpenXml Table error "

elements are required before every "

I have created a Word template that I am then processing via the OpenXML SDK to replace some of the content of the document with data from a database query. The template consists of some basic text with Plain Text Content controls injected in the…
Martin Robins
  • 6,033
  • 10
  • 58
  • 95
12
votes
4 answers

OpenXML SDK Spreadsheet starter kits

I am trying to start working with Excel documents through the OpenXML SDK Spreadsheet API. But I haven't 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…
jmw
  • 2,864
  • 5
  • 27
  • 32
12
votes
1 answer

How to work with style Index in Open xml?

Can Anyone please explain How Style Index in OpenXml works? I have a business requirement where I need to apply background color to certain cells in an excel sheet. And Some style is already applied to other cells. So I need to decide which style…
Raxit J Prajapati
  • 123
  • 1
  • 1
  • 5
12
votes
1 answer

Office Open XMl SDK Writing Numbers to Sheet

I am trying wo write Numbers from a DataTable to an Datasheet - unfortunately, this does not work as expected, e. g. the DataSheet is corrupted. I am using the following code: private void AddDataToSheet(ExcelViewData data, SheetData sheetData) { …
Christian Sauer
  • 10,351
  • 10
  • 53
  • 85
11
votes
3 answers

How to replace an Paragraph's text using OpenXML Sdk

I am parsing some Openxml word documents using the .Net OpenXml SDK 2.0. I need to replace certain sentences with other sentences as part of the processing. While iterating over the paragraphs, I know when I've found something I need to replace, but…
Chaitanya
  • 5,203
  • 8
  • 36
  • 61
11
votes
2 answers

Embed contents of a RTF file into a DOCX file using OpenXML SDK

In our old MSWord-97 based system we use COM to interact with a .doc file, and embed an OLE object, so the embedded document is visible in the parent (not as an icon). We're replacing this with a system using OpenXML SDK since it requires having…
Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
11
votes
2 answers

openXML spreadsheetdocument return byte array for MVC file download

I'm trying to return a openXML spreadsheetdocument as a byte[] which I can then use to allow my MVC to send that file to a user. here is my spreadsheetdocument method to return the byte array using (MemoryStream mem = new MemoryStream()) { …
Canvas
  • 5,779
  • 9
  • 55
  • 98
11
votes
3 answers

OpenXML distance, size units

What are the measurement units used to specify sizes or X,Y cordinates in OpenXML? (Presentation). Does it makes sense to match those with pixels, if so how can be those converted to pixels? graphicFrame.Transform = new Transform(new Offset() { X =…
BuddhiP
  • 6,231
  • 5
  • 36
  • 56
11
votes
3 answers

OpenXML replace text in all document

I have the piece of code below. I'd like replace the text "Text1" by "NewText", that's work. But when I place the text "Text1" in a table that's not work anymore for the "Text1" inside the table. I'd like make this replacement in the all…
TheBoubou
  • 19,487
  • 54
  • 148
  • 236
11
votes
4 answers

OpenXml Cannot open package because FileMode or FileAccess value is not valid for the stream

The stream comes from an html form via ajax var jqXHR = data.submit(); public static GetWordPlainText(Stream readStream,string filePath) { WordprocessingDocument.Open(readStream, readStream.CanRead); } [HttpPost] public ActionResult FileUpload()…
hidden
  • 3,216
  • 8
  • 47
  • 69
10
votes
4 answers

Can I use the Open XML SDK in Mono?

Can the Open XML SDK be used in Mono?
akosch
  • 4,326
  • 7
  • 59
  • 80
10
votes
1 answer

DocumentFormat.OpenXml in Ubuntu server

I have a basic C# application where Open XML SDK is used. I want to make it run in my Nginx & Ubuntu & DigitalOcean server. The application compiles and works well in Windows, and my Mac with mono. Then, I installed mono in the Ubuntu server, and…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
10
votes
4 answers

Automated Testing OpenXML SDK

I'm implementing ms word document generation using content controls and OpenXML SDK. I'd like to have some automated testing for that code (unit tests or some easy UI automation tests). Does anyone has expericnce with testing MS Word document…
Andrii
  • 2,402
  • 1
  • 19
  • 17
10
votes
1 answer

How to convert open xml string to word document c#

I am reading one element from code and I am getting Open XML string as a result. byte[] binary = Convert.FromBase64String(template.Attributes["body"].ToString()); string bodyContent = UnicodeEncoding.UTF8.GetString(binary); Now, I want to…
Mittal Patel
  • 808
  • 1
  • 22
  • 37