NewLife.Office
1.6.2026.1201
dotnet add package NewLife.Office --version 1.6.2026.1201
NuGet\Install-Package NewLife.Office -Version 1.6.2026.1201
<PackageReference Include="NewLife.Office" Version="1.6.2026.1201" />
<PackageVersion Include="NewLife.Office" Version="1.6.2026.1201" />
<PackageReference Include="NewLife.Office" />
paket add NewLife.Office --version 1.6.2026.1201
#r "nuget: NewLife.Office, 1.6.2026.1201"
#:package NewLife.Office@1.6.2026.1201
#addin nuget:?package=NewLife.Office&version=1.6.2026.1201
#tool nuget:?package=NewLife.Office&version=1.6.2026.1201
NewLife.Office - Office Automation Library
🌐 简体中文 | 繁體中文 | 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/net11.0, with AOT compatibility analysis (IsAotCompatible, zero IL warnings) on net8.0+ - MIT licensed: free with no commercial license risk
- Unified API:
NewLife.Officenamespace with a consistent API style, low learning cost
CSV parsing and writing are handled by
CsvFileinNewLife.Core; this library addsCsvDocumentandExcelDataFrame.FromCsv/ToCsvso CSV can be analyzed and routed like a workbook.
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/net11.0; CI covers win-x64 / win-x86 / win-arm64 / linux-x64 / linux-arm64 / osx-x64 / osx-arm64 / linux-loongarch64 (LoongArch via QEMU), with 24 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/*.ymlare 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 | ✅ | ✅ | ✅ | — | 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 |
| ✅ | ✅ | — | — | — | 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)
# Install as a .NET global tool (command: office)
dotnet tool install -g NewLife.Office.Cli
# Any office document → Markdown
office convert input.docx output.md
# doc (97-2003) → docx (legacy document migration)
office doc2docx legacy.doc legacy.docx
AI & Agents
Every mainstream format exposes the same "read structure → apply anchored patch" workflow, plus a cross-format entry:
using NewLife.Office;
// Structure snapshot (docx/xlsx/pptx/pdf, auto-detected)
var outline = OfficeDocumentTool.ReadOutline("report.xlsx");
Console.WriteLine(outline.Content);
// Apply a JSON patch; nothing is written if any op fails
var result = OfficeDocumentTool.ApplyPatch("report.xlsx", patchJson, "out.xlsx");
if (!result.Success) Console.WriteLine($"{result.Code}: {result.Message}");
# CLI: read / apply / text / range / search for all four formats
office read report.xlsx
office apply report.xlsx patch.json out.xlsx
# MCP server (stdio) for VS Code / Claude
office mcp
Anchors and patch operations per format: MCP & Agent Integration.
AI-generated C# code can use ExcelDataFrame for data cleanup, derived columns, multi-key aggregation, joins, pivoting, Top-N and rolling statistics without a Python runtime:
using System;
using NewLife.Office.Excel;
using static NewLife.Office.Excel.AggregateSpec;
using var reader = new ExcelReader("sales.xlsx");
var document = reader.ReadExcel();
var summary = ExcelDataFrame.FromWorksheet(document.GetSheet("Sales"))
.Where(row => row.Number("Sales") > 0)
.DropMissing("Region", "Sales")
.AddColumn("TaxIncluded", row => row.Number("Sales") * 1.13)
.GroupBy("Region", "Month")
.Aggregate(
Sum("Sales", "TotalSales"),
Average("TaxIncluded", "AverageTaxIncluded"));
document.Worksheets.Add(summary.ToWorksheet("Summary"));
document.Save("sales-summary.xlsx");
This API processes table data in memory and does not calculate Excel formulas. Use the streaming reader for larger files.
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. | |
| NewLife.XCode | Data middleware: single tables at the tens-of-billions scale, automatic sharding, read-write splitting, 10+ databases. | |
| 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. | |
| NewLife.Remoting | Protocol communication and RPC framework for client/server applications and IoT devices. | |
| NewLife.Agent | Installs .NET applications as OS daemons: Windows services and Linux systemd. | |
| NewLife.Templates | dotnet new project templates for console, web, API, service, data and IoT projects. |
|
| Data & Messaging | ||
| NewLife.Redis | Redis client with microsecond latency, millions of ops/s and built-in message queues. | |
| NewLife.RocketMQ | Pure managed RocketMQ client for Apache RocketMQ and Alibaba Cloud Message Queue. | |
| NewLife.MQTT | MQTT client and server, including Alibaba Cloud IoT connectivity. | |
| NewLife.NovaDb | Hybrid database in C#: embedded or networked, relational, time-series, message queue and KV in one. | |
| NewLife.MySql | MySql driver and helper layer built on the NewLife data stack. | |
| NewLife.TDengine | Pure managed TDengine ADO.NET driver with REST, WebSocket and native RPC transports, no native dependency. | |
| NewLife.Presto | Pure C# Presto/Trino ADO.NET driver with zero third-party dependencies and XCode ORM integration. | |
| Web & Distributed | ||
| NewLife.Cube | Rapid admin-platform framework: permissions, SSO, OAuth server and CRUD scaffolding. | |
| NewLife.Cube.React | Decoupled front-end sample for Cube: WebAPI backend with Swagger plus React, Vue and Blazor clients. | |
| Stardust | Distributed service platform: node management, APM, configuration center, registry and release center. | |
| AntJob | Distributed task and real-time data scheduling platform with sharding, retries and backfill. | |
| AI & Vision | ||
| NewLife.AI | Unified client for 46 LLM providers plus ChatAI, a ready-to-run web chat application. | |
| NewLife.Imaging | Pure managed imaging foundation: pixel model, codec contracts, drawing and metadata with zero native dependencies. | — |
| NewLife.Vision | Vision algorithms: OCR, barcodes, object detection and face recognition on top of NewLife.Imaging. | — |
| NewLife.ML | Tabular machine learning for .NET: turn database tables and Excel sheets into deployable prediction and classification models. | — |
| Industrial & IoT | ||
| NewLife.IoT | IoT standard library defining protocol contracts and device abstractions. | |
| NewLife.Modbus | Modbus TCP/RTU/ASCII implementation on top of NewLife.IoT. | |
| NewLife.Siemens | Siemens PLC protocol on top of NewLife.IoT. | |
| NewLife.Omron | Omron PLC protocol on top of NewLife.IoT. | |
| NewLife.Melsec | Mitsubishi Melsec PLC protocol on top of NewLife.IoT. | |
| NewLife.Schneider | Schneider PLC communication driver built on Modbus TCP. | |
| NewLife.OPC | OPC client for industrial data access. | — |
| NewLife.BACnet | BACnet building-automation protocol stack. | |
| NewLife.LoRa | LoRaWAN low-power wide-area protocol for long-range IoT connectivity. | |
| 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. | |
| NewLife.JT809 | JT/T 809 platform-to-platform protocol for transport authorities. | |
| NewLife.JT1078 | JT/T 1078 in-vehicle video: RTP parsing, FLV/fMP4 remuxing and live streaming. | |
| Domain Components | ||
| NewLife.Office | One package for Excel, Word, PPT, PDF and 15+ document formats. | |
| NewLife.Audio | Cross-platform audio: codecs, device I/O, DSP, containers and streaming. | |
| NewLife.Video | Video codecs, container formats, frame processing and streaming. | |
| NewLife.Map | Unified interface over Baidu, AMap, Tencent and Tianditu with geocoding and coordinate conversion. | |
| NewLife.IP | IPv4 geolocation with an offline memory-mapped database and an online API fallback. | |
| NewLife.Holiday | Chinese holiday and adjusted-workday identification library with built-in annual data and lunar festival support, fully offline. | |
| Tools & Products | ||
| CrazyCoder | Developer toolbox: network, serial port, crypto, regex, Modbus and MQTT. | |
| NewLife.UnitTest | Unit test extensions: test base classes, data-driven tests and dependency-injection helpers. | |
| 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, Office extensions, protocol drivers and more) are available under the NewLifeX organization and on newlifex.com.
Team
<img src="https://newlifex.com/logo.png" width="48" align="right" alt="NewLife" />
Founded in 2002, the NewLife team has spent more than two decades on the .NET and IoT ecosystem, maintains nearly 100 open-source projects (44 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
<details> <summary>WeChat Official Account: 智能大石头 (scan to follow)</summary>
</details>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5
- NewLife.Core (>= 12.1.2026.1201)
-
.NETStandard 2.0
- NewLife.Core (>= 12.1.2026.1201)
-
.NETStandard 2.1
- NewLife.Core (>= 12.1.2026.1201)
-
net10.0
- NewLife.Core (>= 12.1.2026.1201)
-
net11.0
- NewLife.Core (>= 12.1.2026.1201)
-
net8.0
- NewLife.Core (>= 12.1.2026.1201)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on NewLife.Office:
| Package | Downloads |
|---|---|
|
NewLife.Cube.Core
Cube MVC/Razor layer of the NewLife framework: ASP.NET Core MVC hosting, Razor view templates, user permission management, SSO sign-in, OAuth server, data export and runtime localization, validated with 10 billion rows in a single table. 魔方MVC/Razor兼容层:支持ASP.NET Core MVC传统开发模式,提供用户权限管理、Razor视图模板、SSO登录、OAuth服务端、数据导出与运行时多语言,单表100亿级数据验证。 |
|
|
NewLife.Cube
Cube Web API library of the NewLife framework: entity controllers, permission and menu management, field metadata, OAuth server, JWT authentication and runtime localization. Built for front-end/back-end separation with Vue, Blazor and Ant Design front ends, validated with 10 billion rows in a single table. 魔方WebAPI核心库:实体控制器、权限管理、菜单管理、字段元数据、OAuth服务端、JWT认证与运行时多语言;支持前后端分离架构,对接Vue/Blazor/Antd等前端框架,单表100亿级数据验证。 |
|
|
NewLife.ChatAI
集对话前端、统一 AI 网关、Agent 平台于一身的完整 AI 应用。支持多轮对话、流式输出、函数调用、图像生成、会话管理与使用量统计 |
|
|
NewLife.Office.Rendering
Rendering extension for NewLife.Office, providing document page to image rendering, image processing, watermark overlay and QR code generation, powered by SkiaSharp for cross-platform 2D graphics. NewLife.Office 的渲染扩展包,提供文档页面→图片渲染、图片处理、水印叠加、二维码生成等功能。依赖 SkiaSharp 实现跨平台 2D 图形渲染。 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.6.2026.1201 | 366 | 12/1/2026 |
| 1.5.2026.1120-beta0617 | 966 | 11/20/2026 |
| 1.5.2026.1116-beta0542 | 155 | 11/16/2026 |
| 1.5.2026.1115-beta1618 | 138 | 11/15/2026 |
| 1.5.2026.1103-beta0424 | 109 | 11/3/2026 |
| 1.5.2026.1024 | 1,624 | 10/24/2026 |
| 1.5.2026.1024-beta0331 | 146 | 10/24/2026 |
| 1.4.2026.1022-beta0157 | 126 | 10/22/2026 |
| 1.4.2026.1019-beta1504 | 268 | 10/19/2026 |
| 1.4.2026.1019-beta0438 | 150 | 10/19/2026 |
| 1.4.2026.1018-beta1727 | 160 | 10/18/2026 |
| 1.4.2026.1017-beta1414 | 524 | 10/17/2026 |
| 1.4.2026.1017-beta0929 | 275 | 10/17/2026 |
| 1.4.2026.918-beta0817 | 160 | 9/18/2026 |
| 1.4.2026.917-beta1453 | 161 | 9/17/2026 |
| 1.4.2026.901 | 969 | 9/1/2026 |
| 1.4.2026.901-beta1624 | 124 | 9/1/2026 |
| 1.3.2026.810-beta1534 | 706 | 8/10/2026 |
| 1.3.2026.801 | 775 | 8/1/2026 |
| 1.3.2026.801-beta1828 | 168 | 8/1/2026 |
新增 ExcelDataFrame 表格分析(筛选/分组汇总/关联/透视/交叉表/相关系数/重采样/滚动统计)与 CSV 桥接;新增 Word 编辑底座与构建 API(图片、批注、样式、修订、域与目录、多节页眉页脚);新增四格式 AI 操作接口与统一工具层;加固不可信文档解析并修复 XSS/注入类问题;PDF 加密与签名对齐标准,修复 PDF ToUnicode、XLSX core.xml 命名空间、SetCellFormat 生效等兼容问题;目标框架新增 net11.0