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

C# OpenXML (Word) Table AutoFit to Window

Open a Word (2007/2010) document that has a table in it, select the table and right click, select AutoFit-->AutoFit to Window How can I implement this action in C# using the OpenXML SDK 2.5?
yazanpro
  • 4,512
  • 6
  • 44
  • 66
9
votes
3 answers

OpenXML SDK Inject VBA into excel workbook

I can successfully inject a piece of VBA code into a generated excel workbook, but what I am trying to do is use the Workbook_Open() event so the VBA code executes when the file opens. I am adding the sub to the "ThisWorkbook" object in my xlsm…
Ian Herbert
  • 1,071
  • 2
  • 16
  • 35
9
votes
1 answer

OpenXml: What is the difference between SdtBlock and SdtCell?

SdtCell and SdtBlock in OpenXml.Wordprocessing both serialize into so what is the difference? I assume one is a table cell, which is what the Microsoft documentation appears to imply. The details provided are sparse at best, please clarify.
emd
  • 1,173
  • 9
  • 21
9
votes
1 answer

OpenXML sdk Modify a sheet in my Excel document

I create an empty template in excel. I would like to open the template and edit the document but I do not know how to change the existing sheet. That's the code: using (SpreadsheetDocument xl = SpreadsheetDocument.Open(filename, true)) {…
Dario
  • 101
  • 1
  • 7
9
votes
2 answers

"SaveAs" Wordprocessingdocument (Open XML) file is locked

I have the following code to save a Word document via OpenXML SDK into a new document via "SaveAs". I then want to try and read the file created from ASP.Net, however I am unable to do so as the file is locked and is not released until the app pool…
Dean
  • 360
  • 1
  • 10
  • 27
9
votes
1 answer

Excel add data to WorksheetPart in code behind

Hello guys I am creating an Excel file with 3 worksheets in the following code. using (SpreadsheetDocument spreadSheet = SpreadsheetDocument.Create(path + @"\UrlReport.xlsx", SpreadsheetDocumentType.Workbook)) { // create…
theDawckta
  • 874
  • 3
  • 11
  • 25
9
votes
1 answer

How can I embed any file type into Microsoft Word without interop assemblies

I'm trying to do this How can I embed any file type into Microsoft Word using OpenXml 2.0 but only using the OpenXml SDK 2.5 (no interop assemblies ) I can embed other word (or office) files using the following code sample from here (We need to add…
George Vovos
  • 7,563
  • 2
  • 22
  • 45
9
votes
5 answers

How to access OpenXML content by page number?

Using OpenXML, can I read the document content by page number? wordDocument.MainDocumentPart.Document.Body gives content of full document. public void OpenWordprocessingDocumentReadonly() { string filepath =…
HaBo
  • 13,999
  • 36
  • 114
  • 206
9
votes
1 answer

How to insert text into a content control with the Open XML SDK

I'm trying to develop a solution which takes the input from a ASP.Net Web Page and Embed the input values into Corresponding Content Controls within a MS Word Document. The MS Word Document has also got Static Data with some Dynamic data to be Embed…
Bryan Jacob
  • 145
  • 1
  • 1
  • 6
9
votes
1 answer

Calculate the size (Extents) of a text (TextBody) in OpenXML (PresentationML) PowerPoint (PPTX)

I want to create a presentation with data coming from a database. I manage to get valid presentations that open in PowerPoint (the Open XML Productivity Tool of the SDK 2.5 is a big help in doing this). But, how to calculate the size of the textbox…
outofmind
  • 1,430
  • 1
  • 20
  • 37
9
votes
2 answers

OpenXML SDK 2.5 unreadable content

I am working on taking an existing Excel File which already has all of its formulas and formatting, I add data to the a sheet with a Table and when I then open that file in Excel I get the error "Excel completed file level validation and repair.…
scripter78
  • 1,117
  • 3
  • 22
  • 50
9
votes
1 answer

Using Excel sheet as a template vs. a "real" Excel template in OpenXML

Does anyone have any good answer what kind of difference there is between using some arbitrary pre-formatted Excel 2007 *.xlsx file as a template, loading it in my C# app, and filling up some of its cells with data using the Microsoft OpenXML SDK…
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
9
votes
1 answer

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…
Maulik
  • 91
  • 3
9
votes
3 answers

OpenXml SpreadsheetDocument.Open(...) get exception - The main part is missing

I have an xlsx doc with headers and it is located in my project path. I want to insert data using OpenXML but I get an exception while opening the file: using (SpreadsheetDocument myDoc = SpreadsheetDocument.Open(MyxlsFileName, true)) { //…
Shir
  • 253
  • 1
  • 6
  • 18
9
votes
2 answers

OpenXML Add paragraph style (Heading1,Heading2, Head 3 Etc) to a word processing document

Can anybody guide me how to add predefined styles on paragraph using open XML Word Processing? I have tried various solutions available on forums but nothing works for me. Here is what i want to accomplish: // Create a document by supplying the…
Nabeel
  • 784
  • 3
  • 9
  • 23