Angri450.Nong.Docx 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Angri450.Nong.Docx --version 1.0.2
                    
NuGet\Install-Package Angri450.Nong.Docx -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Angri450.Nong.Docx" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Angri450.Nong.Docx" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Angri450.Nong.Docx" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Angri450.Nong.Docx --version 1.0.2
                    
#r "nuget: Angri450.Nong.Docx, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Angri450.Nong.Docx@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Angri450.Nong.Docx&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Angri450.Nong.Docx&version=1.0.2
                    
Install as a Cake Tool

Angri450.Nong.Docx

农学生文档生成库——OpenXML 底层直接控制,不是 COM 套壳。

为什么做这个

写论文最痛苦的不是内容,是格式。

市面上的方案:python-docx 太底层、pandoc 不可逆、COM 必须装 Office。我们要的是:内容写完,格式一步到位

核心能力

StyleBuilder.BuildFromJson — 一键排版

// dissect 模板 → format.json → 自动加载
StyleBuilder.BuildFromJson(sp.Styles, "formats/life-sciences-contest.json");

// 换格式 = 换 JSON。竞赛论文→期刊论文→学位论文,三秒切。

DocumentWriter — 链式写内容

new DocumentWriter(body)
    .Title("桃树重茬根腐病研究")
    .EnglishTitle("Peach replant root rot study")
    .Abstract("从重茬土壤中分离...")
    .Keywords("重茬;尖孢镰刀菌")
    .Heading("引言", 1)
    .Body("桃树重茬障碍是制约...")
    .Table("抑菌率测定", 1, headers, rows)
    .Heading("讨论", 1)
    .Body("本研究系统完成了...")
    .BibHeading()
    .References("王中林. 桃重茬障碍[J]. ...");
// 链式调用,`[N]` 自动上标,Heading 自动编号

WordPreview — 生成即诊断

var r = WordPreview.Preview("paper.docx");
Console.WriteLine(r.Text);       // 结构化文本预览
// r.Warnings 检查:元素顺序、图片链接、CJK 字体、批注残留...

发稿前跑一次,确保 Word 打开不出错。

ElementOrder.RectifyTree — 底层修复

OpenXML 对元素顺序有严格要求。Word 宽容打开但 Google Docs/WPS 可能乱。Save 前自动修正。

快速开始

dotnet add package Angri450.Nong.Docx
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocxCore;

using var doc = WordprocessingDocument.Create("paper.docx", WordprocessingDocumentType.Document);
var body = new Body();
doc.AddMainDocumentPart().Document = new Document(body);

var sp = doc.MainDocumentPart!.AddNewPart<StyleDefinitionsPart>();
sp.Styles = new Styles();
StyleBuilder.BuildAll(sp.Styles);  // 或 BuildFromJson

var w = new DocumentWriter(body);
w.Title("论文标题").Abstract("摘要...").Keywords("A;B;C")
 .Heading("引言", 1).Body("正文[1]。")
 .BibHeading().References("作者. 标题[J]. 期刊, 年.");

body.Append(new SectionProperties(/* A4 2cm margin */));
ElementOrder.RectifyTree(body);
doc.MainDocumentPart.Document.Save();

三兄弟

用途
Angri450.Nong.Docx Word 文档(本包)
Angri450.Nong.Excel Excel 表格
Angri450.Nong.Pptx PowerPoint 演示

统一 API 风格,统一 Preview→Build→Validate 流水线。

支持的格式模板

  • 生命科学竞赛(限 4 页,无个人信息)
  • 中文期刊(GB/T 7714 顺序编码制)
  • 学位论文(小四宋体,1.5 倍行距)
  • 本科课程论文

换格式 = 换 format.json,不改代码。

协议

Apache-2.0。基于开源的 DocumentFormat.OpenXml SDK

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Angri450.Nong.Docx:

Package Downloads
Angri450.Nong.MultiModal

多模态文档处理库 — OCR、语音转文字、文字转语音。首个能力:PaddleOCR-VL-1.6 云端 API + 本地 PaddleOCR CPU 混合识别。

Angri450.Nong.Inspect

AI-generated content inspection toolkit. Reviews academic papers, official documents, letters, charts, and diagrams for formatting, structure, and content quality issues. Built on Angri450.Nong.Docx.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.1.0 40 6/2/2026
3.0.2 102 6/1/2026
3.0.1 54 6/1/2026
3.0.0 63 6/1/2026
2.0.0 51 5/30/2026
1.0.7 43 5/30/2026
1.0.6.1 48 5/30/2026
1.0.6 55 5/30/2026
1.0.5 82 5/25/2026
1.0.4 81 5/25/2026
1.0.3 84 5/25/2026
1.0.2 86 5/25/2026
1.0.1 94 5/24/2026
1.0.0 86 5/24/2026