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 56,401版本:2026.9剛剛發布

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 IronPDF
預約您的免費現場演示
Booking Badge

全球數百萬工程師信賴

Iron Software的客戶標誌
獲取您的無義務諮詢
完成以下表單或發郵件至sales@ironsoftware.com
您的詳細資訊將始終保持機密。
全球數百萬工程師信賴
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立