Open-XML-SDK

Open XML SDK by Microsoft

Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402 (2 ratings)
Rated 5.0 out of 5
Subscribe to updates I use Open-XML-SDK


Statistics on Open-XML-SDK

Number of watchers on Github 1564
Number of open issues 23
Average time to close an issue 3 months
Main language C#
Average time to merge a PR 1 day
Open pull requests 16+
Closed pull requests 20+
Last commit 10 months ago
Repo Created over 4 years ago
Repo Last Updated 10 months ago
Size 47.6 MB
Homepage https://www.nuget...
Organization / Authorofficedev
Latest Releasev2.8.1
Contributors5
Page Updated
Do you use Open-XML-SDK? Leave a review!
View open issues (23)
View Open-XML-SDK activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating Open-XML-SDK for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)
What people are saying about Open-XML-SDK Leave a review
Good

Open XML SDK

NuGet Downloads master MyGet

The Open XML SDK provides tools for working with Office Word, Excel, and PowerPoint documents. It supports scenarios such as:

  • High-performance generation of word-processing documents, spreadsheets, and presentations.
  • Populating content in Word files from an XML data source.
  • Splitting up (shredding) a Word or PowerPoint file into multiple files, and combining multiple Word/PowerPoint files into a single file.
  • Extraction of data from Excel documents.
  • Searching and replacing content in Word/PowerPoint using regular expressions.
  • Updating cached data and embedded spreadsheets for charts in Word/PowerPoint.
  • Document modification, such as adding, updating, and removing content and metadata.

Table of Contents

Releases

The official release NuGet packages for Open XML SDK are available on Nuget.org.

The NuGet package for the latest builds of the Open XML SDK is available as a custom feed on MyGet. You can trust this package source, since the custom feed is locked and only this project feeds into the source. Stable releases here will be mirrored onto NuGet and will be identical.

For latests changes, please see the changelog

Supported platforms

This library supports many platforms. There are builds for .NET 3.5, .NET 4.0, .NET 4.6, and .NET Standard 1.3. The following platforms are currently supported:

Platform Minimum Version
.NET Framework 3.5
.NET Core 1.0
UWP 10.0
Mono 3.5
Xamarin.iOS 10.0
Xamarin.Mac 3.0
Xamarin.Android 7.0

WindowsBase or System.IO.Packaging

There is a known issue in WindowsBase that causes crashes when handling large data sources. This is fixed in later versions of the library, based on the platform availability of the System.IO.Packaging package. When possible, we use this package instead of WindowsBase. This not only fixes the crash seen by some users, but is available cross platform. However, it is only available on .NET Standard 1.3+ and .NET Framework 4.6+. For this reason, the NuGet package has multiple targets to bring in, when possible. The targets are determined by NuGet at installation and build time and are listed in the table below.

Platform System.IO.Packing Source Tested by
.NET 3.5 WindowsBase N/A
.NET 4.0 WindowsBase .NET 4.5.2
.NET 4.6 NuGet .NET 4.6
.NET Standard NuGet .NET Core 1.0

Keep in mind, though, that the System.IO.Packaging on .NET 4.6+ is simply a facade over WindowsBase, and thus everything running on .NET 4.6 will use WindowsBase instead of the newer implementation.

How to install the NuGet package

The package you want to install is DocumentFormat.OpenXml.

NuGet packages are available for release builds or CI Builds and follow semantic versioning.

The package feed or the package source is specified by the feed URL. Depending on your version of Visual Studio, choose the appropriate feed URL from the table below.

Table 1: The latest builds are available via a MyGet feed.

Client Feed URL
NuGet V3 (Visual Studio 2015+) https://dotnet.myget.org/F/open-xml-sdk/api/v3/index.json
NuGet V2 (Visual Studio 2012+) https://dotnet.myget.org/F/open-xml-sdk/api/v2

The Install-Package command considers the package source either via configuration or argument. Also, the package version can vary. For the latest version info, see the feed for the DocumentFormat.OpenXml package.

  • To specify the package source via a configuration option, see Configuring NuGet behavior. Note that usually a NuGet.config file is placed in the directory and the configuration options are added there to ensure the sources are persisted in the version control.
  PM> Install-Package DocumentFormat.OpenXml -Version <version retrieved from the web>
  • To pass the feed URL as an argument, here is an example for Visual Studio 2015 and later.
  PM> Install-Package DocumentFormat.OpenXml -Version <version retrieved from the web> -Source https://dotnet.myget.org/F/open-xml-sdk/api/v3/index.json

Note: If you have trouble installing the package, try restarting Visual Studio. Package sources could be cached and changes you've made to any NuGet.config files may not be detected.

If You Have Problems

If you want to report a problem (bug, behavior, build, distribution, feature request, etc...) with the SDK built by this repository, please feel free to post a new issue and someone will try to help.

If you have how-to questions please post to one of the following resources:

Known Issues

  • On Mono platforms that use the System.IO.Package NuGet package (i.e. Xamarin), opening some documents will fail due to an issue in System.IO.Packaging. For now, you must manually set the environment variable as described in UriKind.RelativeOrAbsolute workaround.
  • On .NET Core, zip packages do not have a way to stream data. Thus, the working set can explode in certain situations. This is a known issue.
  • On .NET Framework, an IsolatedStorageException may be thrown under certain circumstances. This generally occurs when manipulating a large document in an environment with an AppDomain that does not have enough evidence.

Note: Once System.IO.Packaging on .NET Core has feature parity with WindowsBase (i.e. streaming support), we can investigate using the new .NET Core on .NET Framework.

Documentation

The functionality of the specific classes in this version of the Open XML SDK is similar to version 2.5, therefore the Open XML SDK 2.5 for Office documentation available on MSDN is still accurate.

In addition to open sourcing of the SDK, Microsoft has opened up the conceptual documentation for public review / contributions. A copy of the documentation is available for you to edit and review in GitHub.

Build Instructions

This project uses the csproj format and the release versions of the tooling in Visual Studio 2017. For more information on how to use this project type to build your project, see the release notes for Visual Studio 2017. Other editors that support the latest .NET project files include Visual Studio Code, Visual Studio for Mac, or .NET CLI. See .NET Downloads for details.

The project often requires the latest release of the C# compiler as many new features come on-line that greatly aid in ease of development. As of now, the C# 7.2 compiler is required (which was released in December 2017) and comes standard in Visual Studio 2017 Update 5, with other IDEs providing updates to the compiler, as well.

To build the Open XML SDK

  1. Clone the Open-XML-SDK repository.
  2. Open the solution with an editor that supports the latest .NET project files.
  3. Build the solution (using either Debug or Release configuration).
  4. Run the Xunit tests to verify the installation.

If you want to use a command line approach:

  1. Go to the directory that contains the solution.
  2. Run dotnet restore in the directory.
  3. Run dotnet test DocumentFormat.OpenXml.Tests to run the tests.
  4. Run dotnet pack DocumentFormat.OpenXml to generate a nupkg.

Related tools

  • Open XML Powertools: This is available on in the Open-Xml-PowerTools repository on GitHub and provides example code and guidance for implementing a wide range of Open XML scenarios.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Open-XML-SDK open issues Ask a question     (View All Issues)
  • about 2 years Add support .NET Standard
  • about 2 years OutOfMemoryException when writing large Spreadsheet
  • over 2 years ZipPackage _containerStream isn't closed when a exception is thrown in the ZipArchive constructor
  • over 2 years Invalid IL Code. Xamarin console exe on OSX
  • over 2 years Install Open XML SDK in a Ubuntu server
  • over 2 years Why is auxHint namespace (Auxiliary XML Document 2003) not mapped with strong names?
  • over 2 years Productivity Tool usability
  • over 2 years GenerateCode Functionality
  • over 2 years Open-XML-SDK on Linux
  • over 2 years OpenXML doesn't retrieve correct display formatted data
  • over 2 years Support for UWP
  • over 2 years .NetCore 1.0 RC2 Support
  • over 2 years Incorrect font names when chart added from Excel to PowerPoint
  • over 2 years OpenXML integration with Windows RMS (Right Management Services)
  • over 2 years Changing Document Type Renames Workbook.xml to Workbook2.xml
  • over 2 years Validation fails for different culture
  • almost 3 years SpreadSheet custom map add x: to defaultNamespace
  • almost 3 years Provide official SDK in chocolatey, NuGet, OneGet
  • almost 3 years Incorrect path in Target attribute of <Relationship> tag
  • almost 3 years Productivity Tool validation vs OpenXmlValidator
  • almost 3 years Invalid path to xl workbook
  • almost 3 years 'Invalid Hyperlink' exception when opening the document
  • almost 3 years Open XML SDK does not properly process MP4 files
  • almost 3 years Move to Automatic Package Restore process for nuget
  • almost 3 years Validator reports error for valid "0" values in pageSetup attributes
  • almost 3 years openxml doesn't retrieve the same value than what VBA gives
  • almost 3 years [OSX/MONO] 'The entry is already currently open for writing' errors when running tests
  • almost 3 years [OSX] test failures due to hard coded path separators?
  • about 3 years Support for .NET Core
  • about 3 years Open XML SDK Documentation and Samples
Open-XML-SDK open pull requests (View All Pulls)
  • Migration to xUnit 2.1
  • fix hard coded path separators in tests
  • Case sensitive path issue: BugRegression -> bugregression
  • Fix unit tests on environments with non-US regional settings
  • Code cleanup - introducing the 'nameof' operator instead of string values
  • Add link to download page
  • Abstract binary formatter schema validation
  • Update reflection for .NET Standard
  • Convert the project to project.json for multitargeting
  • Replace a couple APIs not supported in .NET Standard
  • Update XmlDOMTextWriter to derive from XmlWriter
  • Update office2016 from master
  • Update FxCop and VSTest to stable versions
  • Create single ValidationContext and remove mutability from validators
  • Update schema availability attributes
  • Add tests for Part URI helper
Open-XML-SDK questions on Stackoverflow (View All Questions)
  • How to get all merge fields of word document using open xml sdk
  • Is there any way to assign Id's to paragraphs in Open XML SDK 2.5?
  • How to replace content in template docx document and Open XML SDK 2.0 (Aug 09)?
  • Cannot create documents with Open XML SDK
  • Reading cell contents in an Excel file with F# and Open XML SDK
  • Export DataTable to Excel with Open Xml SDK in c#
  • Reading a date from xlsx using open xml sdk
  • Open XML SDK to edit Active document
  • How to include multiple layouts such as Title&Content , Title , Two Content to the masterslide in PPT in open xml sdk 2.5?
  • Open xml sdk with Sharepoint CSOM
  • Inserting a Template into a Template - C# Open XML SDK 2.0/2.5
  • Working with WindowsBase and Open XML SDK 2.5, I cannot use SPFile
  • Open XML SDK for JavaScript spreadsheeml
  • Open XML SDK Productivity Tools: Refactor reflected code
  • How to populate the content controls with real data from custom xml part using open xml sdk?
  • Adding Spreadsheets with open XML SDK
  • Two CellValues with Different Styles in a cell in OPEN XML SDK 2.0
  • C# Open XML SDK 2.5 - make Shape uneditable, unresizeable and immovable
  • How to auto fit columns with open xml SDK excel
  • Open XML SDK cell formatting Javascript
  • Export Data to excel using Open XML SDK Sax type approach
  • How to replace bookmark in Word document (docx) with an image using Open XML SDK?
  • Read uploaded pptx file with Open XML SDK
  • Find a Word check box control by its Tag property using Open XML SDK
  • How to set active sheet with Open XML SDK 2.5
  • base64 encoded image (.png) to byte[] insert into xml (open xml sdk) - ' ', hexadecimal value 0x0B, is an invalid character
  • Open XML SDK disassemble PowerPoint presentation
  • C#, Write XLSX using OpenXmlWriter and Open XML SDK
  • Creating a powerpoint doc with Open XML SDK 2.5 - Server side in Web API
  • Read using OleDbConnection created xlsx file using Open xml SDk
Open-XML-SDK list of languages used
Open-XML-SDK latest release notes
v2.8.1 2.8.1 Release

Changed

  • Corrected package license file reference to show updated MIT License
v2.8.0 2.8.0 Release

Bug fixes, System.IO.Packaging upgrade, more...

v2.7.2 2.7.2 Release

Fixes assembly versioning and a few other issues.

Other projects in C#