TL;DR: Syncfusion’s Excel Library offers a full-fledged object mannequin that facilitates accessing and manipulating Excel paperwork with out Microsoft Workplace or interop dependencies. Let’s study to create Excel tables with this complete software in simply three easy steps.
The Syncfusion Excel Library, often known as Important XlsIO, is a strong software that facilitates the graceful creation, studying, and enhancing of Excel paperwork utilizing C#. It helps the creation of Excel paperwork from scratch, modification of current Excel paperwork, information import and export, Excel formulation, conditional codecs, information validations, charts, sparklines, tables, pivot tables, pivot charts, template markers, and rather more.
Take pleasure in a clean expertise with Syncfusion’s Excel Library! Get began with a number of traces of code and with out Microsoft or interop dependencies.
Discover Now
This weblog will discover the steps to create an Excel desk utilizing the Syncfusion Excel Library and C#.
Word: Please confer with the .NET Excel Library’s getting began documentation earlier than continuing.
Steps to create a desk in Excel
Comply with these steps to create a desk in an Excel doc utilizing C#:
- First, create a .NET Core Console utility in Visible Studio, as proven within the following picture.
- Then, set up the most recent Syncfusion.XlsIO.NET.Core NuGet package deal to your app.
- Now, add the next code to create a desk within the current Excel doc.
utilizing Syncfusion.XlsIO; namespace ExcelTable { class Program { public static void Fundamental() { Program program = new Program(); program.CreateTable(); } /// <abstract> /// Creates a desk within the current Excel doc. /// </abstract> public void CreateTable() { utilizing (ExcelEngine excelEngine = new ExcelEngine()) { IApplication utility = excelEngine.Excel; utility.DefaultVersion = ExcelVersion.Xlsx; FileStream fileStream = new FileStream("../../../Information/SalesReport.xlsx", FileMode.Open, FileAccess.Learn); IWorkbook workbook = utility.Workbooks.Open(fileStream, ExcelOpenType.Automated); IWorksheet worksheet = workbook.Worksheets[0]; AddExcelTable("Table1", worksheet.UsedRange); string fileName = "../../../Output/Desk.xlsx"; //Saving the workbook as stream. FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite); workbook.SaveAs(stream); stream.Dispose(); } } /// <abstract> /// Provides a desk to the worksheet with the given title and vary. /// </abstract> /// <param title="tableName">Desk title</param> /// <param title="tableRange">Desk vary</param> public void AddExcelTable(string tableName, IRange tableRange) { IWorksheet worksheet = tableRange.Worksheet; //Create a desk with the info in a given vary. IListObject desk = worksheet.ListObjects.Create(tableName, tableRange); //Set the desk model. desk.BuiltInTableStyle = TableBuiltInStyles.TableStyleMedium14; } } }
Witness the chances in demos showcasing the sturdy options of Syncfusion’s C# Excel Library.
Strive Now
Seek advice from the next photos.
Word: For extra particulars, confer with working with Excel desk in C# documentation.
GitHub reference
You can too obtain the instance for making a desk in Excel utilizing C# on GitHub.
Do not accept atypical spreadsheet options. Change to Syncfusion and improve the best way you deal with Excel recordsdata in your apps!
Strive It Free
Conclusion
Thanks for studying! On this weblog, we explored tips on how to create tables in Excel paperwork utilizing C# and Syncfusion Excel Library (XlsIO). The Excel Library additionally means that you can export Excel information to photos, information tables, CSV, TSV, HTML, collections of objects, ODS, JSON, and different file codecs.
Take a second to peruse the import information documentation, the place you’ll uncover further importing choices and options resembling information tables, assortment objects, grid view, information columns, and HTML, all accompanied by code samples.
Be at liberty to check out this versatile .NET Excel Library and share your suggestions within the feedback part of this weblog submit!
For current prospects, the brand new model of Important Studio is accessible for obtain from the License and Downloads web page. In case you are not but a Syncfusion buyer, you’ll be able to attempt our 30-day free trial to take a look at our out there options.
For questions, you’ll be able to contact us via our help discussion board, help portal, or suggestions portal. We’re at all times comfortable to help you!