How to Create New Spreadsheets in C#
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.
Get started making PDFs with NuGet now:
Install IronXL with NuGet Package Manager
Copy and run this code snippet.
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);Deploy to test on your live environment
Minimal Workflow (5 steps)
- Download the C# library for creating spreadsheets
- Use the static `Create` method to create a spreadsheet
- Choose whether to create an `XLSX` or `XLS` file
- Export the workbook and check the Excel file
- Use the `CreatingOptions` class to configure the workbook creation
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.
:path=/static-assets/excel/content-code-examples/how-to/create-spreadsheet-create-spreadsheet.csusing 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.
:path=/static-assets/excel/content-code-examples/how-to/create-spreadsheet-spreadsheet-type.csusing 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
XLSformat - 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:
:path=/static-assets/excel/content-code-examples/how-to/create-spreadsheet-creating-options.cs// THIS CODE SNIPPET IS NOT AVAILABLE!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.
:path=/static-assets/excel/content-code-examples/how-to/create-spreadsheet-export-workbook.cs// THIS CODE SNIPPET IS NOT AVAILABLE!Best Practices for Creating Spreadsheets
When creating spreadsheets programmatically with IronXL, consider these best practices:
- Memory Management: Always dispose of
workbookobjects when done, especially when processing multiple files - Error Handling: Implement try-catch blocks to handle potential file system or format errors
- Licensing: Ensure you have properly configured your license key for production use
- 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:
- Learn about managing worksheets within your workbooks
- Explore creating spreadsheets with advanced features
- Discover how to add formulas and calculations to your spreadsheets
Start with our comprehensive getting started guide to explore all of IronXL's capabilities for Excel automation in C#.
Frequently Asked Questions
How do I create a new Excel spreadsheet in C#?
You can create a new Excel spreadsheet in C# using IronXL's WorkBook.Create() method. This single-line API generates a new workbook in XLSX format by default, eliminating the need for complex Excel interop dependencies. Simply call WorkBook workBook = WorkBook.Create(); to get started.
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 initially contains no worksheets, so you must add at least one worksheet using CreateWorkSheet() before working with data. This creates a clean workbook structure ready for data manipulation.
Can I create XLS files instead of XLSX?
Yes, you can create XLS files by specifying the format parameter in IronXL's Create method. Use WorkBook.Create(ExcelFileFormat.XLS) to create a workbook in the older XLS format instead of the default XLSX format.
Why does the library default to XLSX format?
IronXL defaults to XLSX because it's the current industry standard. XLSX offers better compression, improved data recovery, and support for modern Excel features. These files are smaller than XLS counterparts and support larger worksheets with up to 1,048,576 rows by 16,384 columns.
How do I add data to my newly created spreadsheet?
After creating a workbook with IronXL, add a worksheet using CreateWorkSheet(), then set cell values directly. For example: workSheet["A1"].Value = "Hello World"; You can assign various data types including strings, numbers, and DateTime objects to cells.
Can I use CreatingOptions to configure workbook creation?
Yes, IronXL provides the CreatingOptions class to configure workbook creation. This allows you to customize various settings when generating new spreadsheets, giving you more control over the initial workbook structure and properties.






