We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How can I create an Excel document from scratch in aspose.excel?

I’ve been reading through the documentation on aspose.excel, and after running the demos I am still confused as to how I can create a new Excel document using aspose.excel…

Is there some sort of interface that will let me do this? Or does aspose.excel not support its own excel document creation interface.

Could somebody give me some sample code for this if possible?


Dear Greg,

Thanks for your consideration.

A simple sample:

//Create a new Excel object
Excel excel = new Excel();

//Put data

Cells cells = excel.Worksheets[0].Cells;
cells[“A1”].PutValue(“Hello, World”);

//Save file to disk
excel.Save(“d:\book1.xls”, FileFormatType.Default);

Aspose.Excel is discarded and is replaced with a latest product Aspose.Cells which contains all the latest features available in different versions of MS Excel. It is quite easy to use and the best in terms of performance. You may try the following sample code using this latest product which creates an Excel file from scratch.

// Instantiate a Workbook object that represents Excel file.
Workbook wb = new Workbook();

// When you create a new workbook, a default "Sheet1" is added to the workbook.
Worksheet sheet = wb.Worksheets[0];

// Access the "A1" cell in the sheet.
Cell cell = sheet.Cells["A1"];

// Input the "Hello World!" text into the "A1" cell
cell.PutValue("Hello World!");

// Save the Excel file.
wb.Save(dataDir + "MyBook_out.xlsx", SaveFormat.Excel97To2003);

For a basic sample to read/write the Excel file, follow the link below:
Your First Aspose.Cells Application - Hello World

Here is link to download the latest version of Aspose.Cells:
Aspose.Cells for .NET (Latest Version)

A runnable solution containing a lot of sample codes are available here.