Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active February 17, 2022 16:59
C# Generate Excel Reports | Aspose.Cells for .NET

Generate Microsoft Excel spreadsheets from a template sheet using .NET Cells API

C# assembly code listed below for ODS, XLS, XLSB, XLSM, XLSX formats, demonstrating how to create Microsoft Excel spreadsheets from a template sheet. Developers can easily integrate and modify these as of their application requirement.

More details of generating Excel documents using .NET Excel Library at https://products.aspose.com/cells/net/assembly/

For code integration there are few prerequisite listed in installation section below.

Installation

Install from command line as nuget install Aspose.Cells or via Package Manager Console of Visual Studio with Install-Package Aspose.Cells.

Alternatively, get the offline MSI installer or DLLs in a ZIP file from downloads.

More About C# Excel API

Home | Product Page | Docs | Demos | API Reference | Examples | Blog | Search | Free Support | Temporary License

// instantiate a new Workbook designer
var designer = new Aspose.Cells.WorkbookDesigner();
// get the first worksheet of the workbook
var sheet = designer.Workbook.Worksheets[0];
// set the marker to a cell A1
sheet.Cells["A1"].PutValue("&=$VariableArray");
// set the data source for the marker
designer.SetDataSource("VariableArray", new string[] { "English", "Arabic", "Hindi", "Urdu", "French" });
// process the marker
designer.Process(false);
// save the result in ODS format
designer.Workbook.Save("output.xlsx");
// instantiate a new Workbook designer
var designer = new Aspose.Cells.WorkbookDesigner();
// get the first worksheet of the workbook
var sheet = designer.Workbook.Worksheets[0];
// set the marker to a cell A1
sheet.Cells["A1"].PutValue("&=$VariableArray");
// set the data source for the marker
designer.SetDataSource("VariableArray", new string[] { "English", "Arabic", "Hindi", "Urdu", "French" });
// process the marker
designer.Process(false);
// save the result in XLS format
designer.Workbook.Save("output.xls");
// instantiate a new Workbook designer
var designer = new Aspose.Cells.WorkbookDesigner();
// get the first worksheet of the workbook
var sheet = designer.Workbook.Worksheets[0];
// set the marker to a cell A1
sheet.Cells["A1"].PutValue("&=$VariableArray");
// set the data source for the marker
designer.SetDataSource("VariableArray", new string[] { "English", "Arabic", "Hindi", "Urdu", "French" });
// process the marker
designer.Process(false);
// save the result in XLSB format
designer.Workbook.Save("output.xlsb");
// instantiate a new Workbook designer
var designer = new Aspose.Cells.WorkbookDesigner();
// get the first worksheet of the workbook
var sheet = designer.Workbook.Worksheets[0];
// set the marker to a cell A1
sheet.Cells["A1"].PutValue("&=$VariableArray");
// set the data source for the marker
designer.SetDataSource("VariableArray", new string[] { "English", "Arabic", "Hindi", "Urdu", "French" });
// process the marker
designer.Process(false);
// save the result in XLSM format
designer.Workbook.Save("output.xlsm");
// instantiate a new Workbook designer
var designer = new Aspose.Cells.WorkbookDesigner();
// get the first worksheet of the workbook
var sheet = designer.Workbook.Worksheets[0];
// set the marker to a cell A1
sheet.Cells["A1"].PutValue("&=$VariableArray");
// set the data source for the marker
designer.SetDataSource("VariableArray", new string[] { "English", "Arabic", "Hindi", "Urdu", "French" });
// process the marker
designer.Process(false);
// save the result in XLSX format
designer.Workbook.Save("output.xlsx");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment