Syncfusion.XlsIO.Base
Example 


Represents the name of the table.
Represents the data range of the table.

Create Method (IListObjects)

Creates a table with specified name and its data range. Adds it to the IListObjects collection.
Syntax
'Declaration
 
Function Create( _
   ByVal name As String, _
   ByVal range As IRange _
) As IListObject
'Usage
 
Dim instance As IListObjects
Dim name As String
Dim range As IRange
Dim value As IListObject
 
value = instance.Create(name, range)

Parameters

name
Represents the name of the table.
range
Represents the data range of the table.

Return Value

Returns a IListObject with the specified name and range.
Remarks
To know more about tables refer Working with Tables
Example
To create table using data from external sources AddEx method can be used. The following code illustrates how a table can be created in a worksheet using data in the worksheet.
using Syncfusion.XlsIO;
            
class Program
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            //Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook= application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0]; 
            
            //Load data
            worksheet["A1"].Text = "Products";
            worksheet["A2"].Text = "Alfreds Futterkiste";
            worksheet["A3"].Text = "Antonio Moreno Taqueria";
            worksheet["A4"].Text = "Around the Horn";
            worksheet["A5"].Text = "Bon app";
            worksheet["A6"].Text = "Eastern Connection";
            worksheet["A7"].Text = "Ernst Handel";
            worksheet["B1"].Text = "Qtr1";
            worksheet["B2"].Number = 744.6;
            worksheet["B3"].Number = 5079.6;
            worksheet["B4"].Number = 1267.5;
            worksheet["B5"].Number = 1418;
            worksheet["B6"].Number = 4728;
            worksheet["B7"].Number = 943.89;
            worksheet["C1"].Text = "Qtr2";
            worksheet["C2"].Number = 162.56;
            worksheet["C3"].Number = 1249.2;
            worksheet["C4"].Number = 1062.5;
            worksheet["C5"].Number = 756;
            worksheet["C6"].Number = 4547.92;
            worksheet["C7"].Number = 349.6;
            
            //Create style for table number format
            IStyle style1 = workbook.Styles.Add("CurrencyFormat");
            style1.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* \" - \"??_);_(@_)";
            
            //Apply number format
            worksheet["B2:C8"].CellStyleName = "CurrencyFormat";
            
            //Create table
            IListObject table1 = worksheet.ListObjects.Create("Table1", worksheet["A1:C7"]);
            
            //Apply builtin style
            table1.BuiltInTableStyle = TableBuiltInStyles.TableStyleMedium9;
            
            //Total row
            table1.ShowTotals = true;
            table1.Columns[0].TotalsRowLabel = "Total";
            table1.Columns[1].TotalsCalculation = ExcelTotalsCalculation.Sum;
            table1.Columns[2].TotalsCalculation = ExcelTotalsCalculation.Sum;
            
            //Apply AutoFit
            worksheet.UsedRange.AutofitColumns();
            
            //Save and Dispose
            workbook.SaveAs("Tables.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.1460.0.47

See Also