How to Create New Spreadsheets

XLSX is a modern file format for storing Microsoft Excel spreadsheets. It uses the Open XML standard, introduced in Office 2007. XLSX supports advanced features like charts and conditional formatting and is widely used for data analysis and business tasks.

XLS is the older binary format for Excel files used in earlier versions. It lacks the features of XLSX and is now less common.

IronXL offers the capability to create both XLSX and XLS files with just a single line of code.


Get started with IronXL

Start using IronXL in your project today with a free trial.

First Step:
green arrow pointer


Create Spreadsheet Example

Use the static method Create to create an Excel workbook that can be used to store a collection of sheets or worksheets. By default, this method will create an Excel workbook in XLSX format.

:path=/static-assets/excel/content-code-examples/how-to/create-spreadsheet-create-spreadsheet.cs
using IronXL;

// Create spreadsheet
WorkBook workBook = WorkBook.Create();
Imports IronXL

' Create spreadsheet
Private workBook As WorkBook = WorkBook.Create()
$vbLabelText   $csharpLabel

Choose Spreadsheet Type

The Create method also accepts an ExcelFileFormat enum that you can use to specify whether you want to create an XLSX or XLS file. Both file formats are for storing Microsoft Excel spreadsheets, with XLSX being the modern, XML-based format introduced in Office 2007, while XLS is the older binary format used in earlier versions. XLS is now less common due to its limited features and lower efficiency compared to XLSX.

:path=/static-assets/excel/content-code-examples/how-to/create-spreadsheet-spreadsheet-type.cs
using IronXL;

// Create XLSX spreadsheet
WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLSX);
Imports IronXL

' Create XLSX spreadsheet
Private workBook As WorkBook = WorkBook.Create(ExcelFileFormat.XLSX)
$vbLabelText   $csharpLabel

There is another overload for the Create method, which takes CreatingOptions as a parameter. However, the CreatingOptions class currently has only one property, DefaultFileFormat, which is used to configure whether to create an XLSX or XLS file. Check the code below for reference:

:path=/static-assets/excel/content-code-examples/how-to/create-spreadsheet-spreadsheet-type.cs
using IronXL;

// Create XLSX spreadsheet
WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLSX);
Imports IronXL

' Create XLSX spreadsheet
Private workBook As WorkBook = WorkBook.Create(ExcelFileFormat.XLSX)
$vbLabelText   $csharpLabel

Frequently Asked Questions

What are the differences between XLSX and XLS file formats?

XLSX is an XML-based file format introduced in Office 2007, supporting advanced features like charts and conditional formatting. In contrast, XLS is an older binary format with fewer features and is less efficient.

How can I create a new Excel workbook in C#?

You can create a new Excel workbook in C# using IronXL by calling the static Create method from the WorkBook class. It defaults to creating a workbook in XLSX format.

How do I specify the file format when creating a new Excel workbook?

You can specify the file format when creating a new workbook by using the ExcelFileFormat enum in the Create method of the WorkBook class provided by IronXL.

What is the role of the CreatingOptions class in configuring Excel workbooks?

The CreatingOptions class in IronXL is used to configure workbook creation, specifically to set the default file format to either XLSX or XLS through its DefaultFileFormat property.

How can I add a new worksheet to an existing workbook in C#?

To add a new worksheet to a workbook in IronXL, use the CreateWorkSheet method on your workbook object and provide the desired sheet name.

What steps are involved in creating an Excel spreadsheet using IronXL?

To create an Excel spreadsheet using IronXL, download the library, use the static Create method to generate a workbook, select the file format (XLSX or XLS), and export the workbook using the SaveAs method.

Is it necessary to install any library for creating Excel files in C#?

Yes, you need to install the IronXL library from NuGet to create Excel spreadsheets in C#. This provides the necessary functionality for handling Excel files.

Can I create both XLS and XLSX files with IronXL?

Yes, IronXL allows you to create both XLS and XLSX files, offering flexibility based on your specific project needs.

What is the default file format when creating a new Excel workbook using IronXL?

The default file format when using the Create method in IronXL is XLSX.

Where can I obtain a C# library for creating Excel spreadsheets?

You can download the IronXL library from NuGet, the package manager for .NET, to facilitate creating Excel spreadsheets in C# projects.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.