We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Syncfusion Feedback

Trusted by the world’s leading companies

Syncfusion Trusted Companies

Overview

The Syncfusion® .NET Excel Library (XlsIO) offers comprehensive support for creating, accessing, and formatting tables in Excel worksheets. Users can organize and analyze related data using tables and apply built-in and custom styles. Users can also insert or remove rows and columns, add total rows, and create tables from external connections.

Table code example

This example code shows how to create an Excel table to organize and manage data using the Syncfusion® .NET Excel Library with just a few lines of C# code.

// Initialize Excel engine and application.
using ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
// Create data for the table.
worksheet[1, 1].Text = "Products";
worksheet[1, 2].Text = "Qtr1";
worksheet[1, 3].Text = "Qtr2";
worksheet[1, 4].Text = "Qtr3";
worksheet[1, 5].Text = "Qtr4";
worksheet[2, 1].Text = "Alfreds Futterkiste";
worksheet[2, 2].Number = 744.6;
worksheet[2, 3].Number = 162.56;
worksheet[2, 4].Number = 5079.6;
worksheet[2, 5].Number = 1249.2;
worksheet[3, 1].Text = "Antonio Moreno";
worksheet[3, 2].Number = 5079.6;
worksheet[3, 3].Number = 1249.2;
worksheet[3, 4].Number = 943.89;
worksheet[3, 5].Number = 349.6;
worksheet[4, 1].Text = "Around the Horn";
worksheet[4, 2].Number = 1267.5;
worksheet[4, 3].Number = 1062.5;
worksheet[4, 4].Number = 744.6;
worksheet[4, 5].Number = 162.56;
worksheet[5, 1].Text = "Bon app";
worksheet[5, 2].Number = 1418;
worksheet[5, 3].Number = 756;
worksheet[5, 4].Number = 1267.5;
worksheet[5, 5].Number = 1062.5;
// Create styles for table number format.
IStyle style = workbook.Styles.Add("CurrencyFormat");
style.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* \" - \"??_);_(@_)";
worksheet["B2:E8"].CellStyleName = "CurrencyFormat";
// Create a table.
IListObject table = worksheet.ListObjects.Create("Table1", worksheet["A1:E7"]);
// Apply custom table styles.
ITableStyles tableStyles = workbook.TableStyles;
ITableStyle tableStyle = tableStyles.Add("Table Style 1");
ITableStyleElements tableStyleElements = tableStyle.TableStyleElements;
ITableStyleElement tableStyleElement = tableStyleElements.Add(ExcelTableStyleElementType.SecondColumnStripe);
tableStyleElement.BackColorRGB = Color.FromArgb(217, 225, 242);
ITableStyleElement tableStyleElement1 = tableStyleElements.Add(ExcelTableStyleElementType.FirstColumn);
tableStyleElement1.FontColorRGB = Color.FromArgb(128, 128, 128);
ITableStyleElement tableStyleElement2 = tableStyleElements.Add(ExcelTableStyleElementType.HeaderRow);
tableStyleElement2.FontColor = ExcelKnownColors.White;
tableStyleElement2.BackColorRGB = Color.FromArgb(0, 112, 192);
ITableStyleElement tableStyleElement3 = tableStyleElements.Add(ExcelTableStyleElementType.TotalRow);
tableStyleElement3.BackColorRGB = Color.FromArgb(0, 112, 192);
tableStyleElement3.FontColor = ExcelKnownColors.White;
table.TableStyleName = tableStyle.Name;
// Add the total row.
table.ShowTotals = true;
table.ShowFirstColumn = true;
table.ShowTableStyleColumnStripes = true;
table.ShowTableStyleRowStripes = true;
table.Columns[0].TotalsRowLabel = "Total";
table.Columns[1].TotalsCalculation = ExcelTotalsCalculation.Sum;
table.Columns[2].TotalsCalculation = ExcelTotalsCalculation.Sum;
table.Columns[3].TotalsCalculation = ExcelTotalsCalculation.Sum;
table.Columns[4].TotalsCalculation = ExcelTotalsCalculation.Sum;
// Save the Excel document.
using FileStream outputStream = new FileStream("CustomTableStyle.xlsx", FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);

Key features of Tables

Discover how the table features in the Syncfusion® Excel Library enable efficient data organization and management in Excel, allowing you to create, style, and customize tables.

Table Style

Built-in styles can be applied to tables, enhancing their visual appeal and organization. Tables can also be customized with unique styles to improve data presentation and align with user preferences.

Adding a Total Row

Easily add a total row to your table to automatically calculate sums, averages, or other aggregations for selected columns, providing quick insights into your data.

Creating a Table from External Connection

Establish a connection to external data sources to create a table in Excel. Pull in data from various origins and ensure that your analysis is based on current information. Keep the tables up-to-date by refreshing the external data connection, ensuring that any changes made in the source data are reflected in your Excel table.

Adding Parameters to Query in Excel Table

Customize your data retrieval by adding parameters to the queries within the table. Set parameters as a constant value, a range of cells, or prompt users for input, enhancing flexibility in data management.

Explore Table References

Discover valuable resources from our blog and knowledge base articles to enhance your efficiency in using the table.

Create Excel Table in Just 3 Steps Using C#

Blog

Create Excel Table in Just 3 Steps Using C#

What are the built-in table styles can be applied using C#

Knowledge base

What are the built-in table styles can be applied to the Excel document using C#?

Delete Excel table rows without affecting other columns using XlsIO

Knowledge base

Delete Excel table rows without affecting other columns using XlsIO

How to delete Excel table rows and columns in C#

Knowledge base

How to delete Excel table rows and columns in C#, VB.NET?

How to check if a column exists in Excel table using XlsIO

Knowledge base

How to check if a column exists in Excel table using XlsIO?

How to change a table column name and update the named range in C#, VB.NET

Knowledge base

How to change a table column name and update the named range in C#, VB.NET?

How to convert tables in PDF documents to Excel files

Knowledge base

How to convert tables in PDF documents to Excel files?

Syncfusion .NET Excel Library Resources

Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.

Frequently Asked Questions

Yes. The Syncfusion® Excel library allows the editing of existing worksheet data in an Excel document.

Yes, the Syncfusion® Excel library offers extensive formatting options for tables, allowing users to customize table appearance and enhance data visualization.

Users can easily create tables from external connections using the Syncfusion® Excel library, facilitating seamless integration of external data sources into Excel workbooks.

Yes. You can provide your own name or edit the existing name of a table using the Syncfusion® Excel library.

Yes, the Syncfusion® Excel library supports the application of custom table styles, enabling users to customize table appearances to their specific preferences.

Yes. Table formulas are supported by the Syncfusion® Excel library.

Our Customers Love Us

Having an excellent set of tools and a great support team, Syncfusion® reduces customers’ development time.
Here are some of their experiences.

Rated by users across the globe

Want to create, View, and edit Excel files in C# or VB.NET?

Start a free 30-day evaluation today!
DOWNLOAD FREE TRIAL

No credit card required.

Awards

Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion® is proud to hold the following industry awards.

Scroll up icon