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

Optimal way to Read an Excel file (.xls/.xlsx)

I know that there are different ways to read an Excel file: Iterop Oledb Open Xml SDK Compatibility is not a question because the program will be executed in a controlled environment. My Requirement : Read a file to a DataTable / CUstom Entities…
Ankesh
  • 4,847
  • 4
  • 38
  • 76
59
votes
5 answers

OpenXML SDK returning a number for CellValue instead of cells text

I am using the Open XML SDK to open an Excel xlsx file and I try to read the cellvalue on position A1 in each sheet. I use the following code: using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(openFileDialog1.FileName,…
jwdehaan
  • 1,445
  • 3
  • 13
  • 25
51
votes
5 answers

Save modified WordprocessingDocument to new file

I'm attempting to open a Word document, change some text and then save the changes to a new document. I can get the first bit done using the code below but I can't figure out how to save the changes to a NEW document (specifying the path and file…
Paul
  • 3,072
  • 6
  • 37
  • 58
50
votes
16 answers

reading Excel Open XML is ignoring blank cells

I am using the accepted solution here to convert an excel sheet into a datatable. This works fine if I have "perfect" data but if I have a blank cell in the middle of my data it seems to put the wrong data in each column. I think this is because in…
leora
  • 188,729
  • 360
  • 878
  • 1,366
47
votes
7 answers

What indicates an Office Open XML Cell contains a Date/Time value?

I'm reading an .xlsx file using the Office Open XML SDK and am confused about reading Date/Time values. One of my spreadsheets has this markup (generated by Excel 2010)
Samuel Neff
  • 73,278
  • 17
  • 138
  • 182
47
votes
9 answers

From Excel to DataTable in C# with Open XML

I'm using Visual Studio 2008 and I need create a DataTable from a Excel Sheet using the Open XML SDK 2.0. I need to create it with the DataTable columns with the first row of the sheet and complete it with the rest of values. Does anyone have a…
Rastro
  • 473
  • 1
  • 5
  • 7
45
votes
8 answers

Export DataTable to Excel with Open Xml SDK in c#

My program have ability to export some data and DataTable to Excel file (template) In the template I insert the data to some placeholders. It's works very good, but I need to insert a DataTable too... My sample code: using (Stream OutStream = new…
user1576474
  • 554
  • 1
  • 5
  • 10
37
votes
2 answers

Create page break using OpenXml

I use OpenXml to create Word document with simple text and some tables under this text. How can I force Paragraph with this text to show always on new page? Maybe this paragraph should be some Header but I'm not sure how to do this. Thanks
arek
  • 1,282
  • 4
  • 15
  • 25
37
votes
8 answers

Reading a date from xlsx using open xml sdk

I have a date in format "4/5/2011" (month/day/year) in a xlsx file in one of the cells. Im trying to parse the file and load those data in some classes. So far the part where I parse the cell looks like this: string cellValue = cell.InnerText; if…
Santhos
  • 3,348
  • 5
  • 30
  • 48
34
votes
4 answers

open xml reading from excel file

I want to implement openXml sdk 2.5 into my project. I do everything in this link using DocumentFormat.OpenXml; using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Spreadsheet; using System.IO.Packaging; static void Main(string[]…
altandogan
  • 1,245
  • 6
  • 21
  • 44
33
votes
10 answers

How to include the reference of DocumentFormat.OpenXml.dll on Mono2.10?

I am using C#.net Windows Desktop Application.I want to run these application with other platform also. So, i am using Mono 2.10 as a cross compiler.While running,unexpectedly my Application is terminated by saying the error message like …
Saravanan
  • 11,372
  • 43
  • 143
  • 213
27
votes
2 answers

how can I change the font open xml

How can I change the font family of the document via OpenXml ? I tried some ways but, when I open the document, it's always in Calibri Follow my code, and what I tried. The Header Builder I think is useless to post private static void…
Lucas_Santos
  • 4,638
  • 17
  • 71
  • 118
26
votes
4 answers

Applying % number format to a cell value using OpenXML

I want to apply the % (percentage) number format using open XML C# I have numeric value 3.6 that I want to display that number in excel as `3.6%. How do I achieve that?
Selwyn
  • 1,621
  • 6
  • 21
  • 38
26
votes
4 answers

Simplify/ Clean up XML of a DOCX word document

I have a Microsoft Word Document (docx) and I use Open XML SDK 2.0 Productivity Tool to generate C# code from it. I want to programmatically insert some database values to the document. For this I typed in simple text like [[place holder 1]] in the…
K B
  • 1,330
  • 1
  • 18
  • 30
25
votes
4 answers

C# OPEN XML: empty cells are getting skipped while getting data from EXCEL to DATATABLE

Task Import data from excel to DataTable Problem The cell that doesnot contain any data are getting skipped and the very next cell that has data in the row is used as the value of the empty colum. E.g A1 is empty A2 has a value Tom then while…
Vikas Bansal
  • 10,662
  • 14
  • 58
  • 100
1
2 3
99 100