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 Text("Number"));
table[0, 1] = new TableCell(new Text("First Name"));
table[0, 2] = new TableCell(new Text("Last Name"));
for (int i = 1; i < table.Rows.Count; i++)
{
table[i, 0].AddChild(new Text($"{i}"));
table[i, 1].AddChild(new Text($"---"));
table[i, 2].AddChild(new Text($"---"));
}
// 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
Private table As New Table(5, 3)
' Apply styling
table.Zebra = New ZebraColor("FFFFFF", "dddddd")
' Populate table
table(0, 0) = New TableCell(New Text("Number"))
table(0, 1) = New TableCell(New Text("First Name"))
table(0, 2) = New TableCell(New Text("Last Name"))
For i As Integer = 1 To table.Rows.Count - 1
table(i, 0).AddChild(New Text($"{i}"))
table(i, 1).AddChild(New Text($"---"))
table(i, 2).AddChild(New Text($"---"))
Next i
' Create new Word document from the table
Dim doc As New WordDocument(table)
' Export Word document
doc.SaveAs("Document.docx")