var borderStyles = (BorderStyle[])Enum.GetValues(typeof(BorderStyle));
var doc = new DocumentModel();
doc.Sections.Add(
new Section(doc,
new Table(doc, borderStyles.Length, 1, (row, column) =>
{
var cell = new TableCell(doc, new Paragraph(doc, borderStyles[row].ToString()));
cell.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, borderStyles[row], Color.Red, 2d);
return cell;
})));
var path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Borders.docx");
doc.Save(path);
System.Diagnostics.Process.Start(path);// Get all border styles.
var borderStyles = (BorderStyle[])Enum.GetValues(typeof(BorderStyle));
// Create a new empty document.
var doc = new DocumentModel();
// Insert a table with 1 column and 'borderStyles.Length' rows.
doc.Sections.Add(
new Section(doc,
new Table(doc, borderStyles.Length, 1, (row, column) =>
{
// Create a new table cell with text taken from 'borderStyles' array at index 'row'.
var cell = new TableCell(doc, new Paragraph(doc, borderStyles[row].ToString()));
// Set cell outside borders to red color, with width of 2 points and with border style taken from 'borderStyles' array at index 'row'.
cell.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, borderStyles[row], Color.Red, 2d);
return cell;
})));
// Document will be saved to the Desktop.
var path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Borders.docx");
// Save the document.
doc.Save(path);
// Open the document in Microsoft Word.
System.Diagnostics.Process.Start(path);
Dim borderStyles As BorderStyle() = System.Enum.GetValues(GetType(BorderStyle))
Dim doc = New DocumentModel()
doc.Sections.Add(
New Section(doc,
New Table(doc, borderStyles.Length, 1,
Function(row, column)
Dim cell = New TableCell(doc, New Paragraph(doc, borderStyles(row).ToString()))
cell.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, borderStyles(row), Color.Red, 2.0)
Return cell
End Function)))
Dim path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Borders.docx")
doc.Save(path)
System.Diagnostics.Process.Start(path)' Get all border styles.
Dim borderStyles As BorderStyle() = System.Enum.GetValues(GetType(BorderStyle))
' Create a new empty document.
Dim doc = New DocumentModel()
' Insert a table with 1 column and 'borderStyles.Length' rows.
doc.Sections.Add(
New Section(doc,
New Table(doc, borderStyles.Length, 1,
Function(row, column)
' Create a new table cell with text taken from 'borderStyles' array at index 'row'.
Dim cell = New TableCell(doc, New Paragraph(doc, borderStyles(row).ToString()))
' Set cell outside borders to red color, with width of 2 points and with border style taken from 'borderStyles' array at index 'row'.
cell.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, borderStyles(row), Color.Red, 2.0)
Return cell
End Function)))
' Document will be saved on the Desktop.
Dim path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Borders.docx")
' Save the document.
doc.Save(path)
' Open the document in Microsoft Word.
System.Diagnostics.Process.Start(path)