using IronWord;
using IronWord.Models;
// Create table cell
TableCell cell = new TableCell();
Text textRun = new Text();
textRun.Text = "Sample text";
// Add textrun to the cell
cell.AddText(textRun);
// Configure border style
BorderStyle borderStyle = new BorderStyle();
borderStyle.BorderColor = new IronColor(IronSoftware.Drawing.Color.Black);
borderStyle.BorderValue = IronWord.Models.Enums.BorderValues.Thick;
borderStyle.BorderSize = 5;
// Configure table border
TableBorders tableBorders = new TableBorders() {
TopBorder = borderStyle,
RightBorder = borderStyle,
BottomBorder = borderStyle,
LeftBorder = borderStyle,
};
cell.Borders = tableBorders;
// Create row and add cell
TableRow row = new TableRow();
row.AddCell(cell);
row.AddCell(cell);
// Create table and add row
Table table = new Table();
table.AddRow(row);
// 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 cell
Private cell As New TableCell()
Private textRun As New Text()
textRun.Text = "Sample text"
' Add textrun to the cell
cell.AddText(textRun)
' Configure border style
Dim borderStyle As New BorderStyle()
borderStyle.BorderColor = New IronColor(IronSoftware.Drawing.Color.Black)
borderStyle.BorderValue = IronWord.Models.Enums.BorderValues.Thick
borderStyle.BorderSize = 5
' Configure table border
Dim tableBorders As New TableBorders() With {
.TopBorder = borderStyle,
.RightBorder = borderStyle,
.BottomBorder = borderStyle,
.LeftBorder = borderStyle
}
cell.Borders = tableBorders
' Create row and add cell
Dim row As New TableRow()
row.AddCell(cell)
row.AddCell(cell)
' Create table and add row
Dim table As New Table()
table.AddRow(row)
' Create new Word document from the table
Dim doc As New WordDocument(table)
' Export Word document
doc.SaveAs("Document.docx")