Skip to main content
net10.0.NETFramework4.5net8.0.NETStandard2.0.NETStandard2.1

Office automation library supporting read/write, template filling and format conversion for Excel (xlsx/xls), Word (docx/doc), PowerPoint (pptx/ppt), PDF, Markdown, RTF, ODS, Email (eml/msg), iCalendar, vCard, EPUB and XPS, with zero external dependencies and an MIT license. 办公自动化库,支持 Excel、Word、PPT、PDF、Markdown、RTF、ODS、Email、iCalendar、vCard、EPUB、XPS 等格式的读写、模板填充与格式转换,零外部依赖,MIT 许可。

Published
Oct 22, 2026
2d ago
Total Downloads
14.6K
14,610

Install

dotnet add package NewLife.Office --version 1.4.2026.1022-beta0157
ProductVersions
.NET
net10.0net8.0
.NET Standard
netstandard2.0netstandard2.1
Other
.NETFramework4.5

README

NewLife.Office - Office Automation Library

GitHub top language

GitHub License NuGet Downloads NuGet NuGet prerelease test locales AOT smoke platform arch contributors

🌐 简体中文 | 繁體中文 | Español | Deutsch | 日本語 | Français | Português | Русский | 한국어 | العربية

A comprehensive .NET office automation library covering Excel, Word, PPT, PDF and 15+ document formats in one package

Source: https://github.com/NewLifeX/NewLife.Office
NuGet: NewLife.Office (Rendering package: NewLife.Office.Rendering)

Overview

NewLife.Office is a comprehensive .NET office automation library covering Excel (xlsx/xls), Word (docx/doc), PowerPoint (pptx/ppt), PDF, Markdown, RTF, ODS, Email (eml/msg), iCalendar, vCard, EPUB, XPS, and legacy binary formats based on OLE2/BIFF8, backed by the Rendering extension package (documents → images).

  • Zero external dependencies: only depends on NewLife.Core, built directly on Open XML (ZIP + XML) / PDF / OLE2 file structures
  • Full framework support: net45 / netstandard2.0 / netstandard2.1 / net8.0 / net10.0, with AOT compatibility analysis (IsAotCompatible, zero IL warnings) on net8.0+
  • MIT licensed: free with no commercial license risk
  • Unified API: NewLife.Office namespace with a consistent API style, low learning cost

CSV read/write is provided by CsvFile in NewLife.Core; this library does not duplicate CSV.

Highlights

  • Full format coverage: four core formats + ten lightweight formats + OLE2/BIFF8 legacy formats, all in one library
  • Zero external dependencies: operates directly on file structures, package size <500KB
  • High-fidelity roundtrip: L2/L3 fidelity architecture (model + RawXml/part passthrough), read → modify → write without losing formatting
  • Markdown conversion hub: bidirectional MD↔docx/PDF/HTML/Excel/PPT/Word conversion, a unified entry for AI knowledge base ingestion
  • Rendering extension: NewLife.Office.Rendering (separate NuGet) provides document → image rendering, image processing, and QR codes
  • AOT/cross-platform: zero IL warnings on net8.0 / net10.0; CI covers win-x64 / win-x86 / win-arm64 / linux-x64 / linux-arm64 / osx-x64 / osx-arm64 / linux-loongarch64 (LoongArch via QEMU), with 23 AOT smoke scenarios including all 31 language tables
  • 31-language localization: exception messages, document output labels and assembly metadata are translated for the current culture and fall back to English; Locales/*.yml are compiled into the assembly and work under NativeAOT

Supported Formats

Format Read Write Template Conversion Render Notes
Excel xlsx ✅ ✅ ✅ — — Styles, charts, pivot tables, conditional formatting, images, named ranges, structured tables, comments, sparklines, slicers, threaded comments, hidden rows/columns, streaming read and 1904 date support
Excel xls ✅ ✅ — — — OLE2/BIFF8, BiffReader+BiffWriter read/write, styles/merges/hyperlinks/filters/page setup
Word docx ✅ ✅ ✅ HTML/PDF — Paragraphs, tables, images, headers/footers, comments, content controls, AES encryption, mail merge, find/replace (including text boxes), footnote model, multiple sections; cross-validated with NPOI+OpenXmlValidator
Word doc ✅ — — ✅ doc→docx — MS-DOC, DocReader plain text + paragraph formatting extraction (bold/font size/alignment, etc.) + doc→docx conversion
PPT pptx ✅ ✅ ✅ PDF — Text boxes, images, tables, charts, masters, animations, comments, sections; cross-file merge (with chart/comment/notes fidelity)
PPT ppt ✅ ✅ — — — MS-PPT: PptReader text extraction + PptWriter text slide writing
PDF ✅ ✅ — — — Fluent API, merge/split, encryption, signatures, forms, annotations, PDF-A
Markdown ✅ ✅ — HTML/Word/PDF/all→MD — CommonMark + GFM + typed AST, full-format conversion hub
RTF ✅ ✅ ✅ — — Paragraphs, tables, template fill, image embedding (PNG/JPEG)
ODS ✅ ✅ — — — LibreOffice native format, merged cells, styles, formulas
EML ✅ ✅ — — — RFC 5322 + MIME, attachments, inline images
MSG ✅ — — — — Outlook, OLE2 + MAPI, subject/body/attachments
iCalendar ✅ ✅ — — — RFC 5545 .ics, VEVENT/VTODO/RRULE
vCard ✅ ✅ — — — RFC 6350 .vcf, vCard 3.0/4.0
EPUB ✅ ✅ — — — EPUB 2/3, OPF/Nav/chapters/cover
XPS ✅ ✅ — — — ZIP+XML, Glyphs text extraction, multi-page write, images, metadata
Rendering — — — — ✅ Separate package (SkiaSharp): PDF/Word/PPT/Markdown → images

Quick Start

Unified Text / Markdown Extraction

using NewLife.Office;

// One-liner: extract plain text from any supported format
String? text = OfficeFactory.ReadText("document.docx");
String? text2 = OfficeFactory.ReadText("report.xlsx");

// Extract as Markdown (preserves structure)
String? md = OfficeFactory.ReadMarkdown("slides.pptx");

// doc (97-2003) → docx conversion
OfficeFactory.ConvertDocToDocx("legacy.doc", "legacy.docx");

Command-Line Tool (NewLife.Office.Cli)

# Any office document → Markdown
dotnet run --project NewLife.Office.Cli -- convert input.docx output.md

# doc (97-2003) → docx (legacy document migration)
dotnet run --project NewLife.Office.Cli -- doc2docx legacy.doc legacy.docx

Excel Write and Read

using NewLife.Office;

using var ms = new MemoryStream();
var writer = new ExcelWriter(ms);
writer.WriteHeader("Data", new[] { "编号", "姓名", "金额" }, CellStyle.Header);
writer.WriteRow("Data", new Object?[] { 1, "张三", 1234.56m }, new CellStyle
{
    Border = CellBorderStyle.Thin,
    NumberFormat = "#,##0.00",
});
writer.Save();

ms.Position = 0;
var reader = new ExcelReader(ms, Encoding.UTF8);
var rows = reader.ReadRows("Data").ToList();

More capabilities (object mapping import/export, template fill, format conversion, rendering, etc.) see Requirements and the source examples.

Documentation

Ecosystem Map

NewLife is a layered ecosystem of independently versioned open-source projects. The map below is shared verbatim by every NewLife repository; each project links to its repository and its primary NuGet package.

Project What it does Downloads
Foundation
NewLife.Core Logging, configuration, caching, networking, serialization, scheduling and APM tracing. NuGet
NewLife.XCode Data middleware: single tables at the tens-of-billions scale, automatic sharding, read-write splitting, 10+ databases. NuGet
NewLife.Net High-performance network library: 1.77M pps / 14.5 Gbps on a single machine (TCP 1KB, 2026-10), 4M long-lived TCP connections. NuGet
NewLife.Remoting Protocol communication and RPC framework for client/server applications and IoT devices. NuGet
NewLife.Agent Installs .NET applications as OS daemons: Windows services and Linux systemd. NuGet
NewLife.Templates dotnet new project templates for console, web, API, service, data and IoT projects. NuGet
Data & Messaging
NewLife.Redis Redis client with microsecond latency, millions of ops/s and built-in message queues. NuGet
NewLife.RocketMQ Pure managed RocketMQ client for Apache RocketMQ and Alibaba Cloud Message Queue. NuGet
NewLife.MQTT MQTT client and server, including Alibaba Cloud IoT connectivity. NuGet
NewLife.NovaDb Hybrid database in C#: embedded or networked, relational, time-series, message queue and KV in one. NuGet
NewLife.MySql MySql driver and helper layer built on the NewLife data stack. NuGet
Web, AI & Distributed
NewLife.Cube Rapid admin-platform framework: permissions, SSO, OAuth server and CRUD scaffolding. NuGet
Stardust Distributed service platform: node management, APM, configuration center, registry and release center. NuGet
AntJob Distributed task and real-time data scheduling platform with sharding, retries and backfill. NuGet
NewLife.AI Unified client for 46 LLM providers plus ChatAI, a ready-to-run web chat application. NuGet
Industrial & IoT
NewLife.IoT IoT standard library defining protocol contracts and device abstractions. NuGet
NewLife.Modbus Modbus TCP/RTU/ASCII implementation on top of NewLife.IoT. NuGet
NewLife.Siemens Siemens PLC protocol on top of NewLife.IoT. NuGet
NewLife.Omron Omron PLC protocol on top of NewLife.IoT. NuGet
NewLife.Melsec Mitsubishi Melsec PLC protocol on top of NewLife.IoT. NuGet
NewLife.OPC OPC client for industrial data access. —
NewLife.BACnet BACnet building-automation protocol stack. NuGet
ZeroIoT Lightweight open-source IoT platform with gateway and device management. —
Vehicle Telematics
NewLife.JT808 JT/T 808 vehicle positioning protocol: 70+ message bodies, 2011/2013/2019. NuGet
NewLife.JT809 JT/T 809 platform-to-platform protocol for transport authorities. NuGet
NewLife.JT1078 JT/T 1078 in-vehicle video: RTP parsing, FLV/fMP4 remuxing and live streaming. NuGet
Domain Components
NewLife.Office One package for Excel, Word, PPT, PDF and 15+ document formats. NuGet
NewLife.Audio Cross-platform audio: codecs, device I/O, DSP, containers and streaming. NuGet
NewLife.Video Video codecs, container formats, frame processing and streaming. NuGet
NewLife.Map Unified interface over Baidu, AMap, Tencent and Tianditu with geocoding and coordinate conversion. NuGet
NewLife.IP IPv4 geolocation with an offline memory-mapped database and an online API fallback. NuGet
Tools & Products
CrazyCoder Developer toolbox: network, serial port, crypto, regex, Modbus and MQTT. NuGet
GitCandy Self-hosted Git source code management system. —
LuckyClover Installs the matching .NET runtime automatically when launched from an older host. —

Badges show the primary package of each project; theme, extension and satellite packages are listed on their NuGet pages.The 30+ packages not listed here (FTP, LoRa, Office extensions, protocol drivers and more) are available under the NewLifeX organization and on newlifex.com.

Team

Founded in 2002, the NewLife team has spent more than two decades on the .NET and IoT ecosystem, maintains nearly 100 open-source projects (34 of them core to this map), and delivers integrated software and hardware solutions for power, logistics, healthcare, industrial control and internet industries. We live by the motto "learning has no seniority — mastery earns respect".

Open-source components have been downloaded 6.48M times from NuGet (ecosystem-wide, as of 2026-10).

Website: https://newlifex.com · Open source organization: https://github.com/NewLifeX

WeChat Official Account: 智能大石头 (scan to follow)

智能大石头

Changes from Previous Version

No structural changes between v1.4.2026.1019-beta1504 and v1.4.2026.1022-beta0157.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 5 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.