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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Create simple spreadsheet in C#, VB.NET using XlsIO

Platform: WinForms |
Control: XlsIO |
Published Date: April 30, 2011 |
Last Revised Date: April 9, 2019

Syncfusion Excel (XlsIO) library is a .NET Excel library used to create, read, and edit Excel documents. Also, converts Excel documents to PDF files. Using this library, you can create simple spreadsheet in C#, VB.NET.

XlsIO has a very intuitive object model like Excel object model. So, the process of creating a new spreadsheet is like what you would do using Microsoft Excel.

Steps to create simple spreadsheet using XlsIO, programmatically:

Step 1: Create a new C# console application project.

Create a new C# console application

Step 2: Install the Syncfusion.XlsIO.WinForms NuGet package as reference to your .NET Framework application from NuGet.org.

Install NuGet package

Step 3: Include the following namespace in the Program.cs file.

C#

using Syncfusion.XlsIO;

 

VB.NET

Imports Syncfusion.XlsIO

 

Step 4: Create a new instance of XlsIO. This is equivalent to launching Microsoft Excel, but the difference is that Microsoft Excel will create spreadsheet by default but in XlsIO, we must create spreadsheet after launching an Excel application. At this point we have a workbook object that is like the blank workbook in Microsoft Excel. We can create any number of new workbooks that we want. XlsIO has many APIs that allow you to manipulate the contents and formatting of the spreadsheet just like you would do in Microsoft Excel UI. Use the following code snippet to create simple spreadsheet using XlsIO in C#, VB.NET.

C#

//Create Excel engine
using (ExcelEngine excelEngine = new ExcelEngine())
{
    //Instantiate the application object
    IApplication application = excelEngine.Excel;
 
    //Create spreadsheet or workbook object
    IWorkbook workbook = application.Workbooks.Create(1);
 
    //The first worksheet object in the worksheets collection is accessed
    IWorksheet worksheet = workbook.Worksheets[0];
 
    //A text is set in the first cell of the worksheet
    worksheet[1, 1].Text = "Hello World!";
 
    //Save the spreadsheet
    workbook.SaveAs("Output.xlsx");
}

 

VB.NET

'Create Excel engine
Using excelEngine As ExcelEngine = New ExcelEngine()
    'Instantiate the application object
    Dim application As IApplication = excelEngine.Excel
 
    'Create spreadsheet or workbook object
    Dim workbook As IWorkbook = application.Workbooks.Create(1)
 
    'The first worksheet object in the worksheets collection is accessed
    Dim worksheet As IWorksheet = workbook.Worksheets(0)
 
    'A text is set in the first cell of the worksheet
    worksheet(1, 1).Text = "Hello World!"
 
    'Save the spreadsheet
    workbook.SaveAs("Output.xlsx")
End Using

 

A complete Windows Forms working example of how to create simple spreadsheet using XlsIO in C# and VB.NET can be downloaded from Create Simple Spreadsheet.zip.

By executing the program, you will get the output Excel file as shown below.

Output Excel document

Refer here to explore the rich set of Syncfusion Excel (XlsIO) library features.

See Also:

How do I create a spreadsheet based on an existing template?

Does the XlsIO component support Excel spreadsheets that have VBA code in them?

 How to create an Excel file in Windows Forms

How do I protect certain cells in a spreadsheet?

How do I create a workbook with the specified number of worksheets?

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer the link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon