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 removing tracked revisions or removing unacceptable content from documents.
$ dotnet add package DocumentFormat.OpenXmlThe core Open XML SDK library for working with Office Word, Excel, and PowerPoint documents using strongly-typed .NET APIs.
Create a simple Word document:
using (var doc = WordprocessingDocument.Create("example.docx", WordprocessingDocumentType.Document))
{
var mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document(new Body(new Paragraph(new Run(new Text("Hello, Open XML!")))));
}