|
DocumentAdv document = new DocumentAdv();
SectionAdv section = new SectionAdv();
//Initializes border width as 0.5 points and converted to pixel units by multiplying (96 / 72).
double borderWidth = (0.5) * (96 / 72);
TableAdv table = new TableAdv();
TableFormat tableFormat = new TableFormat();
Borders borders = new Borders();
borders.Left = new Border() { Color = Colors.Black, LineStyle = LineStyle.Single, LineWidth = borderWidth };
borders.Right = new Border() { Color = Colors.Black, LineStyle = LineStyle.Single, LineWidth = borderWidth };
borders.Top = new Border() { Color = Colors.Black, LineStyle = LineStyle.Single, LineWidth = borderWidth };
borders.Bottom = new Border() { Color = Colors.Black, LineStyle = LineStyle.Single, LineWidth = borderWidth };
borders.Horizontal = new Border() { Color = Colors.Black, LineStyle = LineStyle.Single, LineWidth = borderWidth };
borders.Vertical = new Border() { Color = Colors.Black, LineStyle = LineStyle.Single, LineWidth = borderWidth };
tableFormat.Borders = borders;
table.TableFormat = tableFormat;
TableRowAdv row = new TableRowAdv();
TableCellAdv cell = new TableCellAdv();
ParagraphAdv paragraph = new ParagraphAdv();
SpanAdv span = new SpanAdv();
span.Text = "Hello World";
paragraph.Inlines.Add(span);
cell.Blocks.Add(paragraph);
row.Cells.Add(cell);
table.Rows.Add(row);
section.Blocks.Add(table);
document.Sections.Add(section); |