IRONSOFTWAREHOME

How to Create New Spreadsheets in C#

Curtis Chau
Curtis Chau
Updated: August 2, 2026

Creating new spreadsheets in C# is straightforward with IronXL's WorkBook.Create() method, which generates XLSX or XLS files in a single line. This approach eliminates complex Excel interop dependencies and works seamlessly in .NET applications.

Quickstart: Create a new XLSX workbook with IronXL

Use IronXL's single-line API to generate a new workbook in XLSX format - no complex setup needed. This approach lets you build spreadsheets in C# quickly and efficiently.

  1. 1Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. 2Copy and run this code snippet.

    WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
  3. 3Deploy to test on your live environment

    Start using IronXL in your project today with a free trial
    arrow pointer

How Do I Create a Basic Spreadsheet in C#?

Use the static method Create to create an Excel workbook that can store a collection of sheets or worksheets. By default, this method creates an Excel workbook in XLSX format. The IronXL API Reference provides comprehensive documentation on all available methods and properties.

using IronXL;

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

What Happens When I Call WorkBook.Create()?

When you call WorkBook.Create(), IronXL initializes a new in-memory workbook object with default settings. The workbook contains no worksheets initially - you must add at least one worksheet before working with data. This method creates a clean workbook structure ready for your data manipulation needs.

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. For more details on working with Excel features, check our comprehensive features overview.

Why Does IronXL Default to XLSX Format?

IronXL defaults to XLSX because it's the current industry standard, offering better compression, improved data recovery, and support for modern Excel features. XLSX files are smaller than their XLS counterparts and support larger worksheets (up to 1,048,576 rows by 16,384 columns).

XLS is the older binary format for Excel files used in earlier versions. It lacks the features of XLSX and is now less common. However, IronXL supports both formats to ensure compatibility with legacy systems when needed.


How Can I Choose Between XLSX and XLS Formats?

The Create method accepts an ExcelFileFormat enum that specifies whether to create an XLSX or XLS file. Both file formats store 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.

using IronXL;

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

When Should I Use XLS Instead of XLSX?

Use XLS format only when:

  • Your application needs to support Excel 2003 or earlier versions
  • You're integrating with legacy systems that require XLS format
  • Corporate policies mandate the use of older file formats

For all other scenarios, XLSX is recommended due to its superior performance, smaller file sizes, and support for modern Excel features. Learn more about exporting Excel files in various formats.

What Configuration Options Are Available?

Another overload for the Create method takes CreatingOptions as a parameter. Currently, the CreatingOptions class has only one property, DefaultFileFormat, which configures whether to create an XLSX or XLS file. Check the code below for reference:

using IronXL;
using IronXL.Options;

CreatingOptions options = new CreatingOptions();
options.DefaultFileFormat = ExcelFileFormat.XLS;

// Create XLS spreadsheet
WorkBook workBook = WorkBook.Create(options);
C#

How Do I Export the Created Workbook?

After creating and populating your workbook, you have several export options. IronXL supports saving to various formats including XLSX, XLS, CSV, TSV, JSON, XML, and HTML. For detailed guidance on writing Excel values, see our tutorial on writing Excel files in .NET.

using IronXL;

// Create a new workbook and add a worksheet
WorkBook workBook = WorkBook.Create();
WorkSheet workSheet = workBook.CreateWorkSheet("sheet1");

// Populate a cell with sample data
workSheet["A1"].StringValue = "Hello World";

// Export the workbook to XLSX format
workBook.SaveAs("createdSpreadsheet.xlsx");

// Export the workbook to CSV format
workBook.SaveAs("createdSpreadsheet.csv");

// Export the workbook to JSON format
workBook.SaveAs("createdSpreadsheet.json");

// Export the workbook as HTML
workBook.ExportToHtml("createdSpreadsheet.html");
C#

Best Practices for Creating Spreadsheets

When creating spreadsheets programmatically with IronXL, consider these best practices:

  1. Memory Management: Always dispose of workbook objects when done, especially when processing multiple files
  2. Error Handling: Implement try-catch blocks to handle potential file system or format errors
  3. Licensing: Ensure you have properly configured your license key for production use
  4. Performance: For large datasets, consider chunking data writes rather than cell-by-cell operations

For more advanced scenarios, explore our detailed tutorial on creating Excel files in .NET which covers complex formatting, formulas, and styling options.

Next Steps

Now that you know how to create spreadsheets, you might want to:

Start with our comprehensive getting started guide to explore all of IronXL.Excel's capabilities for Excel automation in C#.

Frequently Asked Questions

How do I create a new Excel spreadsheet in C# using IronXL?

You can create a new Excel spreadsheet in C# using IronXL by calling the `WorkBook.Create()` method. This generates a new workbook in either `XLSX` or `XLS` format, eliminating the need for Excel interop dependencies.

What is the default file format when creating a spreadsheet with IronXL?

The default file format when creating a spreadsheet with IronXL is `XLSX`. This format is the current industry standard, providing better compression and support for modern Excel features.

Can IronXL export workbooks to formats other than Excel?

Yes, IronXL can export workbooks to multiple formats including `CSV`, `TSV`, `JSON`, `XML`, and `HTML`, in addition to `XLSX` and `XLS`.

What is the `CreatingOptions` class in IronXL?

The `CreatingOptions` class in IronXL allows you to configure workbook creation options, such as setting the `DefaultFileFormat` to either `XLSX` or `XLS`.

How does IronXL manage Excel file formats?

IronXL uses the `ExcelFileFormat` enum to determine whether an `XLSX` or `XLS` file should be created. This functionality provides flexibility based on the needs of your application or system compatibility.

When should I use the `XLS` format instead of `XLSX` with IronXL?

Use the `XLS` format if your application needs to support Excel 2003 or earlier versions, or if you're integrating with legacy systems that require `XLS` format.

What happens when `WorkBook.Create()` is called in IronXL?

When `WorkBook.Create()` is called, IronXL initializes a new in-memory workbook object with default settings. You must add a worksheet before you can start entering data.

Does IronXL require complex setup to create spreadsheets?

No, IronXL simplifies the spreadsheet creation process with its single-line API, which allows you to generate new workbooks without complex setup.

What are the best practices when using IronXL to create spreadsheets?

Best practices include managing memory by disposing of workbook objects, using try-catch blocks for error handling, ensuring proper license configuration, and optimizing performance when handling large datasets.

What advanced steps can I take after creating spreadsheets with IronXL?

After creating spreadsheets, you can manage worksheets, add formulas and calculations, and explore advanced features such as complex formatting, by referring to IronXL's comprehensive documentation and tutorials.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 2,237,574Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronXL.Excel
nuget.org/packages/IronXL.Excel/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronXL"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronXL to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronXL.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required