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
8
votes
2 answers

How to set active sheet with Open XML SDK 2.5

using the example here How to Copy a Worksheet within a Workbook I have successfully been able to clone/copy sheets in my excel file, however when I open the excel the 2nd sheet is the active(visible) sheet. I haven't been able to locate a property…
drock19
  • 161
  • 1
  • 7
8
votes
2 answers

Comparing Docx files using OOXML

How can I read word-by-word (with styles) from a docx file. I want to compare two docx files word-by-word and based on the differences I have to write into another docx file (using c# and OOXML). I have tried achieving this by using…
user274223
  • 81
  • 1
  • 3
8
votes
2 answers

How to hide a sheet in Excel using OpenXML C#?

I have an Excel Template with various sheets to which I am dumping data retrieved from SQL Server using OpenXML, C#. After I am done with dumping the data, I need to hide some of the sheets based on conditions. I couldn't find any piece of code to…
Raghu
  • 105
  • 1
  • 5
8
votes
2 answers

Inserting new rows and moving exsisting ones with OpenXML SDK 2.0

I'm using OpenXML SDK 2.0 to add data to the spreadsheet template but I ran into a problem (since I've been using OpenXML for a day that's not so hard to believe). I can't figure out how to add new rows while pushing all the rows that are below the…
wegelagerer
  • 3,600
  • 11
  • 40
  • 60
8
votes
3 answers

Getting cell-backgroundcolor in Excel with Open XML 2.0

I am trying to get the backgroundcolor of a cell in a excel-spreadsheet. I am using Open XML 2.0 SDK and I am able to open the *.xlsx-file and to get cell-values for example. My code for getting the Background-Color is the following: public…
basti
  • 2,649
  • 3
  • 31
  • 46
8
votes
2 answers

Download EXCEL file from ASP.NET page without Generating physical file on server (On The Fly)

I am trying to export C# DataTable to EXCEL file on the fly (without creating physical file) using Microsoft Office EXCEL INTEROP and download it through asp.net webpage through Response object. I am able to generate memorystream using the library…
Sankalp
  • 929
  • 1
  • 7
  • 16
7
votes
4 answers

Working with Office "open" XML - just how hard is it?

I'm considering replacing a (very) large body of Office-automation code with something that works with the Office XML format directly. I'm just starting out, but already I'm worried that it's too big a task. I'll be dealing with Word, Excel and…
Gary McGill
  • 26,400
  • 25
  • 118
  • 202
7
votes
3 answers

Corrupt document after calling AddAlternativeFormatImportPart using OpenXml

I am trying to create an AddAlternativeFormatImportPart in a .docx file in order to reference it in the document via an AltChunk. the problem is that the code below causes the docx file to read as corrupted by Word and cannot be opened. …
Leslie Marshall
  • 171
  • 2
  • 3
7
votes
1 answer

Open XML SDK: Format part of an Excel-cell

Using Open XML for Excel with DocumentFormat.OpenXml.Spreadsheet, how do I set only part of a text to bold? var cell = new Cell { //DataType = CellValues.InlineString, CellReference = "A" + 1 }; // TODO: Set "bold text" to bold style //var…
Seb Nilsson
  • 26,200
  • 30
  • 103
  • 130
7
votes
1 answer

Stream into package, package into WordDocument and then back again

I do not understand all the mechanics surrounding Streams and even less around the System.IO.Package class. I have a .docx document as a binary in a DataBase and I wan't to fetch it, modify somewhat and then save it. I currently have the method that…
Ingó Vals
  • 4,788
  • 14
  • 65
  • 113
7
votes
1 answer

Why does my custom XML not carry over to a new version of a DOCX file when Word saves it?

I'm adding in some custom XML to a docx for tracking it inside an application I'm writing. I've manually done it via opening the Word Document via a ZIP library, and via the official Open XML SDK route. Both have the same outcome of my XML being…
John Mc
  • 444
  • 2
  • 15
7
votes
2 answers

OpenXML file download without temporary file

Is there a way of providing a download in an ASP.Net Page for a freshly generated OpenXML (docx) file without saving it in a temporary folder? On MSDN I only found a tutorial for using a temp file but I thought about using the…
Kuepper
  • 992
  • 13
  • 39
7
votes
1 answer

MemoryStream is empty for an OpenXML Excel document

I would normally use ClosedXML to generate Excel files. A Core project is forcing me to use only OpenXML. The resulting Excel file will be downloaded. I am having an issue where the memory stream given to the SpreadsheetDocument is empty. I have…
Darren Wainwright
  • 30,247
  • 21
  • 76
  • 127
7
votes
4 answers

How to ensure that the OpenXml assembly doesn't cause a conflict with SpreadsheetLight?

I Nugot SpreadsheetLight. To subsequently use it, I need to add the following usings: using DocumentFormat.OpenXml; using DocumentFormat.OpenXml.Spreadsheet; using SpreadsheetLight; For the first two ("DocumentFormat") to be recognized, I needed to…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
7
votes
1 answer

OpenXML SDK border on merged cells only applied to first cell

When using the OpenXML SDK to apply a border to a merged cell range, the border is only showing up for the first (top left) cell in the merge range. I have absolutely no idea and this is driving me crazy. Using the productivity tool I can't find…
sovemp
  • 1,402
  • 1
  • 13
  • 31