Angri450.Nong.Docx 1.0.7

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.7
                    
NuGet\Install-Package Angri450.Nong.Docx -Version 1.0.7
                    
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.7" />
                    
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.7" />
                    
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.7
                    
#r "nuget: Angri450.Nong.Docx, 1.0.7"
                    
#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.7
                    
#: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.7
                    
Install as a Cake Addin
#tool nuget:?package=Angri450.Nong.Docx&version=1.0.7
                    
Install as a Cake Tool

Angri450.Nong.Docx

农学生文档生成库——OpenXML 底层直接控制,不是 COM 套壳。纯 .NET,零外部依赖。

为什么做这个

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

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

核心能力

StyleBuilder.BuildFromJson — 一键排版

StyleBuilder.BuildFromJson(sp.Styles, "formats/life-sciences-contest.json");
// 换格式 = 换 JSON。竞赛论文→期刊论文→学位论文,三秒切。

DocumentWriter — 链式写内容

new DocumentWriter(body)
    .Title("氮肥运筹对水稻产量及氮素利用效率的影响")
    .EnglishTitle("Effects of nitrogen management on rice yield and nitrogen use efficiency")
    .Abstract("以粳稻品种为材料,设置4个氮肥处理...")
    .Keywords("水稻;氮肥运筹;产量;氮素利用效率")
    .Heading("引言", 1).Body("正文[1]。")
    .Table("不同氮肥处理下水稻产量构成因素", 1, headers, rows)
    .Figure("图1 实验设计示意图", 1)
    .Heading("讨论", 1)
    .BibHeading().References("作者. 标题[J]. 期刊, 年.");
// 链式调用,[N] 自动上标,Heading 自动编号

ImageEmbedder — 图片嵌入

ImageEmbedder.EmbedImages(body, mainPart, new[] { "fig1.png", "fig2.png" });
// 前两张图自动 1x2 无边框表格并排,第3张起纵向排列
// 自动识别 png/jpeg/gif/bmp/tiff,宽度约束防溢出

TemplateEngine — 文档解剖

var result = TemplateEngine.Analyze("paper.docx");
// 返回:段落结构 + 格式指纹 + 格式污染检测

var files = TemplateEngine.ExtractImages("paper.docx", "images/");
// 提取文档中所有图片

WordPreview — 生成即诊断

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

ElementOrder.RectifyTree — 底层修复

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

快速开始

dotnet add package Angri450.Nong.Docx
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.BuildFromJson(sp.Styles, "formats/life-sciences-contest.json");

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

ImageEmbedder.EmbedImages(body, doc.MainDocumentPart, new[] { "fig1.png", "fig2.png" });

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 演示
Angri450.Nong.Chart 统计分析 + 图表生成

统一 API 风格,统一 Preview→Build→Validate 流水线。Skill 做编排,.NET CLI 做确定性工作。

支持的格式模板

  • 生命科学竞赛(限 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.1 41 6/5/2026
3.1.0 85 6/2/2026
3.0.2 151 6/1/2026
3.0.1 96 6/1/2026
3.0.0 105 6/1/2026
2.0.0 92 5/30/2026
1.0.7 86 5/30/2026
1.0.6.1 87 5/30/2026
1.0.6 97 5/30/2026
1.0.5 84 5/25/2026
1.0.4 81 5/25/2026
1.0.3 84 5/25/2026
1.0.2 87 5/25/2026
1.0.1 96 5/24/2026
1.0.0 86 5/24/2026