Using C# to Create Excel Files in .Net - TV To Talk About | The Tulsa CW

Using C# to Create Excel Files in .Net


Originally posted on


Creating Excel files in C# can be simple even without dependency on the legacy Microsoft.Office.Interop.Excel library.

In this tutorial we will use IronXL to create an Excel WorkBook file on any platform that supports .Net Framework 4.5 or .Net Core.


Before we start we need to install the IronXL Excel NuGet Package.

PM > Install-Package IronXL.Excel

As an alternative, the IronXL.Dll can be downloaded and added to your project.

Create and save an Excel File

  1. using IronXL;
  2. //default file format is XLSX, we can override it using CreatingOptions
  3. WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
  4. var sheet = workbook.CreateWorkSheet("example_sheet");
  5. sheet["A1"].Value = "Example";
  6. //set value to multiple cells
  7. sheet["A2:A4"].Value = 5;
  8. sheet["A5"].Style.SetBackgroundColor("#f0f0f0");
  9. //set style to multiple cells
  10. sheet["A5:A6"].Style.Font.Bold = true;
  11. //set formula
  12. sheet["A6"].Value = "=SUM(A2:A4)";
  13. if (sheet["A6"].IntValue == sheet["A2:A4"].IntValue)
  14. {
  15. Console.WriteLine("Basic test passed");
  16. }
  17. workbook.SaveAs("example_workbook.xlsx");

Moving Forward

To learn more about creating Excel files in C# .Net, we encourage you to work with this code sample and explore the object reference to move forwards to meet you own project’s specific need.

Information contained on this page is provided by an independent third-party content provider. Frankly and this Site make no warranties or representations in connection therewith. If you are affiliated with this page and would like it removed please contact

Powered by Frankly
All content © Copyright 2000 - 2019 KQCW. All Rights Reserved.
For more information on this site, please read our Privacy Policy, and Terms of Service, and Ad Choices.