VegaRise.NET

Table Style

TableStyle controls the layout algorithm, table look (header/footer, banding), width, indent, per-column widths, and cell spacing. Cell-level styling is done with TableCellStyle.

Band Table with Header

Use case: Produce a professional-looking table with a header and alternate row shading.

C#
1var tableStyle = new TableStyle
2{
3 Layout = TableLayoutValues.Autofit,
4 TableLook = new TableLook
5 {
6 FirstRow = true,
7 NoHorizontalBand = false,
8 },
9Width = new DocumentUnit(6.0, Units.inch),
10TableGridColsWidth = new List<DocumentUnit>
11{
12 new DocumentUnit(3.0, Units.inch),
13 new DocumentUnit(3.0, Units.inch),
14},
15};
16
17var table = new Table(3, 2);
18table.Style = tableStyle;

Fixed Column Widths

Use case: Use fixed layout so column widths never change.

C#
1var tableStyle = new TableStyle
2{
3 Layout = TableLayoutValues.Fixed,
4 TableGridColsWidth = new List<DocumentUnit>
5 {
6 new DocumentUnit(100, Units.pt),
7 new DocumentUnit(200, Units.pt),
8 new DocumentUnit(100, Units.pt),
9 }
10};

Cell Alignment

Use case: Center-align a header cell and right-align a numeric cell.

C#
1var header = new TableCellStyle
2{
3 VerticalAlignment = TableVerticalAlignmentValues.Center,
4 Justification = TableJustificationValues.center,
5};
6
7var numeric = new TableCellStyle
8{
9 Justification = TableJustificationValues.right,
10};
11
12table[0, 0].Style = header;
13table[1, 1].Style = numeric;

Frequently asked questions

How do I make a header row repeat on every page?

Mark the header row's TableRowStyle.RepeatOnEveryPage = true.

How do I apply the same border to all cells?

Set TableStyle.Borders using a TableBorder (which shares edges and inner borders).

VegaRise.NET

Sign In

Welcome back. Please sign in to your account.

Forgot password?
or

Don't have an account? Create an account

By signing in, you agree to our Terms of Service and Privacy Policy.