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

C# Open Xml SDK 2.0 Spreadsheet Setting Cell DateTime Format

I'm having trouble finding this one. my situation: SDK 2.0 no template spreadsheet C# 4.0 in VS2010 my problem: Certain data in the excel files I want to build exists in DateTime format. As I don't wan't to use just strings (stringed datetimes…
Jan W.
  • 1,761
  • 5
  • 26
  • 28
7
votes
1 answer

How to use a gradient fill (GradientFill) with ClosedXML

I'm working on a C#/ASP.NET web thing and want to do an Excel export. First I found OpenXML, made some first steps, but it's really hard to use. Now, I'm using ClosedXML and it's quite a relief - so far. I came up with the problem to have a gradient…
outofmind
  • 1,430
  • 1
  • 20
  • 37
7
votes
3 answers

OpenXML escaping illegal characters

I am doing some string replacement within a Word Docx file using OpenXML Power Tools and it is working as expected. However things break when I have invalid characters in the substitution such as ampersand, so for instance "Harry & Sally" will break…
TheEdge
  • 9,291
  • 15
  • 67
  • 135
7
votes
1 answer

How to embed font file in OpenXML Word document

I'm building a Word document in OpenXML with C#. One of the fonts I must use is a custom-made branded font. This font will not be available on customer machines. Is it possible to embed font-file within .docx file and reference that font in font…
trailmax
  • 34,305
  • 22
  • 140
  • 234
7
votes
1 answer

Create New Empty Word Document

I'm trying to create an empty Word document (DOCX) using OpenXML SDK 2.5. The following code is not working for me because MainDocumentPart is null. public static void CreateEmptyDocxFile(string fileName, bool overrideExistingFile) { …
yazanpro
  • 4,512
  • 6
  • 44
  • 66
7
votes
0 answers

Creating .pptx file with OpenXML

I want to create a PowerPoint presentation based on a template in C#. I am using the OpenXML 2.0 SDK. My first step. I took my .pptx template, changed it in C# code and copied it in my project. I was able to create slides based on my templates. Now…
Leviathan
  • 282
  • 2
  • 12
7
votes
2 answers

Open XML SDK v2.0 Performance issue when deleting a first row in 20,000+ rows Excel file

Do anyone come across a performance issue when deleting a first row in a 20,000+ rows Excel file using OpenXML SDK v2.0? I am using the delete row coding suggested in the Open XML SDK document. It takes me several minutes just to delete the first…
7
votes
1 answer

Is there a tool to find errors in Excel documents created with the OpenXML SDK?

Is there a tool that can identify the exact location of errors in an Excel document created using the OpenXML SDK? I've created an Excel file using the Microsoft OpenXML SDK 2.5 (also tried v 2.0 with the same result), and must have made a mistake…
Lenny
  • 333
  • 5
  • 19
7
votes
3 answers

Open XML SDK: get "Unreadable content" error when trying to populate more than 25 columns

I have created a spreadsheet using Open XML SDK in C#, and successfully populated two worksheets. When trying to populate a third, I get an "Unreadable content" error when opening the completed document, and it appears to occur when I attempt to…
Rick Burgess
  • 73
  • 1
  • 3
7
votes
2 answers

XLSX- how to get rid of the default namespace prefix x:?

I'm generating XLSX spreadsheet using OOXML SDK, and I need to get rid of x: namespace prefix. How can I achieve this? using (SpreadsheetDocument doc = SpreadsheetDocument.Open("template.xlsx", true)) { //Save the shared…
user116884
  • 81
  • 1
  • 4
7
votes
1 answer

Open XML: Word - Getting all Paragraphs marked as "Heading1" style

Using Word I have created a Docx with the standard normal.dot as a test. Hello-world level complexity. I wish to get all the paragraphs which are styled with the "Heading1" style in Word. I can get all the paragraphs, but don't know how to filter…
Ian Vink
  • 66,960
  • 104
  • 341
  • 555
7
votes
8 answers

Excel found unreadable content in *.xlsx

I am working on generating an excel template from code. When I run the piece to create my WorkBook, I get no errors in code, however when I go to open the Excel document, I get an error indicating that the file is unreadable. I am able to click to…
Kobojunkie
  • 6,375
  • 31
  • 109
  • 164
6
votes
2 answers

OpenXML Power Tools trouble compiling: 'OutputTypeAttribute' could not be found

I am using the OpenXMLSDK for some DOCX manipulation. I am trying to compile the OpenXML Power Tools source for help with this. I read that I needed to instal the MS Power Shell for this to compile (for its use of Cmdlets), so I downloaded it from…
Ian Herbert
  • 1,071
  • 2
  • 16
  • 35
6
votes
1 answer

Using a template with OpenXML and SAX

I'm creating a large XLSX file from a datatable, using the SAX method proposed in Parsing and Reading Large Excel Files with the Open XML SDK. I'm using an XLSX file as a template. The method described in that post works fine to substitute a new…
Jonathan Sayce
  • 9,359
  • 5
  • 37
  • 51
6
votes
3 answers

How do you convert Excel to CSV using OpenXML SDK?

I have a requirement to convert Excel (2010) files to csv. Currently I'm using Excel Interop to open and SaveAs csv, which works well. However the Interop has some issues in the environemt where we use it, so I'm looking for another solution. I…
TheSean
  • 4,516
  • 7
  • 40
  • 50