Angri450.Nong.Docx
1.0.2
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
<PackageReference Include="Angri450.Nong.Docx" Version="1.0.2" />
<PackageVersion Include="Angri450.Nong.Docx" Version="1.0.2" />
<PackageReference Include="Angri450.Nong.Docx" />
paket add Angri450.Nong.Docx --version 1.0.2
#r "nuget: Angri450.Nong.Docx, 1.0.2"
#:package Angri450.Nong.Docx@1.0.2
#addin nuget:?package=Angri450.Nong.Docx&version=1.0.2
#tool nuget:?package=Angri450.Nong.Docx&version=1.0.2
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- DocumentFormat.OpenXml (>= 3.3.0)
- System.Drawing.Common (>= 9.0.4)
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.