Microsoft® Excel Template Based Files Creation via .NET

Generate Excel file reports on the basis of a predefined template within .NET based applications

 

.NET Excel Library supports generating template based Excel files for bulk report generation. Templates are predesigned formats, used for creating same pattern reports. .NET code creates the new excel file same as template document having filled with data. Supported file formats include XLS, XLSX, XLSB, XLSM, ODS.

Create Reports Based on Predesigned Excel Template

To automate the process of creating same pattern files is easy using .NET Assembly API. There are different ways to import data and generate Excel files. API provides a WorkbookDesigner class to represent a designer worksheet. Create its object and use it to open template file. Set the datasource, that may be DataTable, Array, Json file etc. Process it to import data and save the file with data in required format. Programmers can assemble data into reports in other file formats as of below listed links.

C# Code to Generate Excel Reports
// instantiate a new Workbook designer
var dgr = new WorkbookDesigner();
// get the first worksheet of the workbook
var sheet = dgr.Workbook.Worksheets[0];
// set the marker to a cell A1
sheet.Cells["A1"].PutValue("&=$VariableArray");
// set the data source for the marker
dgr.SetDataSource("VariableArray", new string[] { "first", "second", "third", "fourth", "fifth" });
// To Set the datatable as the data source. Firstly populate datatable from any data source
// dgr.SetDataSource(dt);
// process the marker
dgr.Process(true);
// save the result in XLSX format
dgr.Workbook.Save("output.xlsx");