Xceed Workbooks for .NET v1.4 Documentation
Table Class
Members  Example 


Xceed.Workbooks.NET Assembly > Xceed.Workbooks.NET Namespace : Table Class

A Table represents a range of cells in a Worksheet. To be considered a Table, these cells should be independent from the other cells in the Worksheet and grouped to form a rectangular arrangement of rows and columns. Built-in styles can be used to unify these grouped cells visually.

The Table’s header row can display filtering options for each column. A total row can also be added. Each cell of this row will display a formula calculation based on the data in that column (SUM, AVERAGE, COUNT…).

Syntax
'Declaration

 

Public Class Table 

   Inherits WorksheetElement
'Usage

 

Dim instance As Table
public class Table : WorksheetElement 
Example
using( var workbook = Workbook.Create("test.xlsx" ) )

  {

    var worksheetA = workbook.Worksheets[ 0 ];



    // Fill cells values.

    worksheetA.Rows[ 4 ].Cells[ 6 ].Value = "Fruits";

    worksheetA.Rows[ 5 ].Cells[ 6 ].Value = "Strawberry";

    worksheetA.Rows[ 6 ].Cells[ 6 ].Value = "Orange";

    worksheetA.Rows[ 7 ].Cells[ 6 ].Value = "Banana";

    worksheetA.Rows[ 8 ].Cells[ 6 ].Value = "Apple";

    worksheetA.Rows[ 4 ].Cells[ 7 ].Value = "Quantity";

    worksheetA.Rows[ 5 ].Cells[ 7 ].Value = 8;

    worksheetA.Rows[ 6 ].Cells[ 7 ].Value = 2;

    worksheetA.Rows[ 7 ].Cells[ 7 ].Value = 3;

    worksheetA.Rows[ 8 ].Cells[ 7 ].Value = 3;



    // Creates the formatted table from cell (4,6) to cell (8,7), using a medium theme, with the formatted header row displayed.

    worksheetA.Tables.Add( 4, 6, 8, 7, TableStyle.TableStyleMedium20, true );

        

    // Gets this formatted table and sets some properties. Tables and TableColumns can be accessed by position or name.        

    worksheetA.Tables[ 0 ].ShowFirstColumnFormatting = true;

    worksheetA.Tables[ 0 ].ShowBandedRows = true;

    worksheetA.Tables[ 0 ].AutoFilter.ShowFilterButton = false;

    worksheetA.Tables[ "Table1" ].ShowTotalRow = true;

    worksheetA.Tables[ "Table1" ].Columns[ "Fruits" ].TotalRowLabel = "TOTAL:";

    worksheetA.Tables[ "Table1" ].Columns[ "Quantity" ].TotalRowFunction = TotalRowFunction.Sum;



    workbook.Save();

  }
Inheritance Hierarchy

System.Object
   Xceed.Workbooks.NET.WorkbookElement
      Xceed.Workbooks.NET.WorksheetElement
         Xceed.Workbooks.NET.Table

Requirements

Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Table Members
Xceed.Workbooks.NET Namespace