Create an Excel workbook using Spire.XLS


This article is a second part of my article series on a great .NET managed component i.e Spire.XLS. In this we will create a simple Excel worksheet with some typical functions.


In previous post Getting started with spire.xls we learned how to start/setup the component on your computer to start development.


In this post we will see how to create a simple Excel worksheet using Spire.Net component.


Please note that in this demo example we are using free edition of Spire.XLS.

  • Visual studio 2013 express or later edition
  • Current supported version of Spire.XLS

Start creating simple app using Spire.XLS

Lets start developing, our very first and a simpler app which will create an Excel file.


  1. Open your visual studio
  2. Go to File -> New -> Project [Ctr+Shift+N]
  3. Select Web project [in this example we are using mvc project] or you can choose windows project
  4. I named this project as EICeblueStuffs, you can choose as you like J
  5. Choose MVC from project templates
  6. Right click on the project and add reference of Spire.XLS assemblies as per your current .NET version
  7. SpireXLS references

    SpireXLS references

  8. Add ‘ICeblueHelper’ folder.
  9. Add new class file and named it as ‘SpireExcel’

In SpireExce.cs

public void CreateSampleExcel()


workSheet = workBook.Worksheets[0];

workSheet.Range["A1"].Text = "This is a sample Excel dcouemnt and created by Spire.XLS for .NET";

workBook.SaveToFile(_xlsFilePath + _xlsFileName);


It will simply create an Excel workbook with specified name and on a specified path. Where we defined the filename and path see here:

private string _xlsFilePath = HttpContext.Current.Server.MapPath("~/Sample/XLSFiles/");

In above we are grabbing the serve path where our Sample/XLSFiles folder exist.

public SpireExcel()

: this("mySpireExcel.xls")

{ }

public SpireExcel(string xlsFileName)


_xlsFileName = xlsFileName;

workBook = new Workbook();


Just initializing our XLSFileName and our WorkBook object.


You will get the complete code from here: E-Iceblue Stuffs

Just run your project and it will create a simple Excel, now go to the specified path and you can see the excel.

Spire.XLS - sample

Spire.XLS – sample

As we are using free version of Spire.XLS you can see following warning sheet:

Spire.XLS - evaluation warning

Spire.XLS – evaluation warning


In this article we learned how to create a simple Excel file and save the same on specified path.using Spire.XLS J

Leave A Reply