SharpLeaf Reference > Table Class

Table Class

Build a table of text data for SharpLeaf.

public class Table

Example

A Table is generally created in three phases:

  1. Set up table-wide settings
  2. Flow content into cells, possibly changing settings on the way
  3. Include table into SharpLeaf report with the IncludeTable method.
  // Set up table-wide settings
   tb = new Table();
   tb.SetTitles(1,1);  // 1 column and 1 row of titles
   tb.SetOffset(1,0);  // Offset table box to exclude 1 column and 0 row
   tb.SetCellMargins(10);  // More space around cell content
   tb.Box = new BoxStyle(3,Color.Navy,LineStyle.Solid,10,Color.Navy,FillStyle.Saturate10,true);
   tb.SetRowGrid(0);  // Disable row grid

  // Go through cells, possibly changing settings on the way
   tb.SetCellFont(new FontType("Times",24,FontStyle.Bold));
   tb.AddRows(new string[]{"","Column 1","Column 2","Column 3"});
   tb.AddColumns(new string[]{"Row 1","Row 2","Row 3","Row 4"});
   tb.SetCellFont(new FontType("Arial",20));
   tb.AddRows(new int[][]{new int[]{101,201,301},new int[]{102,202,302},new int[]{103,
            203,303},new int[]{104,204,304}});

  // Include table in SharpLeaf flow
   lf.IncludeTable(tb);

Have a look at the Table tutorials for more examples.

Constructors

Table Instance Properties

BoxBoxStyle for whole table (null for no box) (default is 1-pt black unfilled)
CaptionText displayed at the top of table on every sub-page
CaptionAlignmentHorizontal Alignment of Caption (Left by default)
CaptionFontFontType for Table Caption (default is null to use working ParagraphStyle)
ColumnColumn index of the current cell pointer
ColumnOverwriteOverwrite column settings when re-visiting columns in future cells (default is false)
ColumnsNumber of columns in current table (ReadOnly)
FootnoteText displayed once at the end of the Table
FootnoteAlignmentHorizontal Alignment of Footnote (Left by default)
FootnoteFontFontType for Table Footnote (default is null to use working ParagraphStyle)
HeadingText displayed once at the beginning the Table
HeadingAlignmentHorizontal Alignment of Heading (Left by default)
HeadingFontFontType for Table Heading (default is null to use working ParagraphStyle)
MergeOrderSet cell merging order when both columns and rows can be merged (default is true for columns first)
RowRow index of the current cell pointer
RowOverwriteOverwrite row settings when re-visiting rows in future cells (default is false)
RowsNumber of rows in current table (ReadOnly)
SubheadingText displayed once at the beginning the Table, below heading
SubheadingFontFontType for Table Subheading (default is null to use working ParagraphStyle)

Table Methods

AddCSVFlow a CSV array into table
AddColumnCellsAppend cells to current column
AddColumnsFlow an array of cells into table as columns, starting from current cell.
AddRowCellsAppend cells to current row.
AddRowsFlow an array of cells into table as rows, starting from current cell.
NextCellMove cell pointer to arbitrary cell
NextColumnMove cell pointer to the next column on the right
NextEmptyColumnMove cell pointer after next non-empty column.
NextEmptyRowMove cell pointer after next non-empty row.
NextRowMove cell pointer down one row.
SetCellAlignmentSet horizontal alignment of table cells (defaults to Alignment.Left)
SetCellBoxSet cell boxes to cycle through from current cell on
SetCellClipSet column right-edge clipping as boolean flags (defaults to true)
SetCellFillCharSet character used to fill cell text up to the column right edge (defaults to whitespace).
SetCellFontSet cell fonts to cycle through from current cell on
SetCellMarginsSet margins above/below/left/right cell content within cell boundary for all table cells (default is 3)
SetCellTextSet a specific cell text, extending table size if necessary.
SetCellVerticalAlignmentSet the vertical alignment of table cells (default is Top)
SetCellWrapSet text wrapping within columns as boolean flags (true by default)
SetColumnAfterSet column right margins to cycle through from current column on (default is 3)
SetColumnBeforeSet column left margins to cycle through from current column on (default is 3)
SetColumnGridSet vertical grid decoration (Defaults to 0.1 black solid)
SetColumnMaxWidthsSet maximum column widths to cycle through from current column on (defaults to -1 for no limit)
SetColumnMergeSet vertical cell merging flags to cycle through from current column on (defaults to false)
SetColumnMinWidthsSet minimum column widths to cycle through from current column on (defaults to 6 – twice the default cell gutter)
SetColumnRetainAdd indices of table columns that should be repeated on all subpages
SetColumnWidthsSet column widths to cycle through from current column on
SetOffsetSet column and row offset of table boxing and grid.
SetRowAfterSet row bottom margins to cycle through from current row on (default is 3)
SetRowBeforeSet row top margins to cycle through from current row on (default is 3)
SetRowGridSet horizontal grid decoration (defaults to 0.1 black solid)
SetRowHeightsSet fixed row heights to cycle through from current row on
SetRowMaxHeightsSet maximum row heights to cycle through from current row on (defaults to -1 for no limit)
SetRowMergeSet horizontal cell merging flags to cycle through from current row on (defaults to false)
SetRowMinHeightsSet minimum row heights to cycle through from current row on (defaults to 6 – twice the default cell gutter)
SetRowRetainAdd indices of table rows that should be repeated on all subpages
SetTitlesSet the number of leading columns and rows that are titles.

See also

Table Tutorials

Requirements

Namespace: Causeway

Assembly: SharpPlot (in sharpplot.dll)


Send comments on this topic
© Dyalog Ltd 2021