IRONSOFTWAREHOME
添加表格
using IronWord;
using IronWord.Models;

// Create table
Table table = new Table(5, 3);

// Apply styling
table.Zebra = new ZebraColor("FFFFFF", "dddddd");

// Populate table
table[0, 0] = new TableCell(new TextContent("Number"));
table[0, 1] = new TableCell(new TextContent("First Name"));
table[0, 2] = new TableCell(new TextContent("Last Name"));
for (int i = 1; i < table.Rows.Count; i++)
{
    table[i, 0].AddChild(new TextContent($"{i}"));
    table[i, 1].AddChild(new TextContent($"---"));
    table[i, 2].AddChild(new TextContent($"---"));
}

// Create new Word document from the table
WordDocument doc = new WordDocument(table);

// Export Word document
doc.SaveAs("Document.docx");
Imports IronWord
Imports IronWord.Models

' Create table
Dim table As New Table(5, 3)

' Apply styling
table.Zebra = New ZebraColor("FFFFFF", "dddddd")

' Populate table
table(0, 0) = New TableCell(New TextContent("Number"))
table(0, 1) = New TableCell(New TextContent("First Name"))
table(0, 2) = New TableCell(New TextContent("Last Name"))
For i As Integer = 1 To table.Rows.Count - 1
    table(i, 0).AddChild(New TextContent($"{i}"))
    table(i, 1).AddChild(New TextContent("---"))
    table(i, 2).AddChild(New TextContent("---"))
Next

' Create new Word document from the table
Dim doc As New WordDocument(table)

' Export Word document
doc.SaveAs("Document.docx")
NuGet Download
PM > Install-Package IronWord
添加表格

添加表格

表格是由行和列排列的单元格组成的网格。 这是一项基本功能,可让您以结构化的方式组织和呈现信息。 表格中行和列的每次交点称为一个单元格。 表格通常用于各种用途,例如创建日程表、整理数据和整齐地排列内容。

要使用IronWord添加表格,首先通过提供行数和列数来实例化一个表格。 根据您的需求自定义整个表格样式。 使用[row, column]格式访问表格的每个单元格。 有了这个,您可以相应地设置每个单元格的样式,并向单元格添加多个文档元素,例如shape。 表格对象设置完成后,即可用于创建新的 Word 文档。

学习如何使用 IronWord 在 Word 中添加表格
在 GitHub 上查看

准备开始了吗?

Nuget Downloads 58,016版本:2026.10刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥。

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronWord
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
您的资料将始终保密。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
深受全球数百万工程师信赖
立即获取您的免费30 天试用密钥。
无需信用卡或创建账户
C# 用于 PDF 的 NuGet 库
通过 NuGet 安装

版本: 2026.10

PM > Install-Package IronWord
nuget.org/packages/IronWord/
  1. 在解决方案资源管理器中,右键点击引用,管理 NuGet 包
  2. 选择浏览并搜索“IronWord”
  3. 选择包并安装
C# PDF DLL
下载 DLL

版本: 2026.10

  1. 下载并解压IronWord到你的解决方案目录中的~/Libs等位置
  2. 在Visual Studio解决方案资源管理器中,右键单击引用。选择浏览,“IronWord.dll”

许可证价格从$999起