Razor Page Samples - Database to Workbook

Use SpreadsheetGear to generate Excel workbooks from a database. Copy data from a DataTable or DataSet into a worksheet with SpreadsheetGear API specifically designed for these objects. Or if you use Entity Framework Core or another ORM, copy the query results to a worksheet with SpreadsheetGear's extensive worksheet and range API.

Entity Framework Core to Workbook

This sample uses a simple Entity Framework Core query to extract some data out of a database and copy it into a worksheet, which can be downloaded to the end-user's computer.

Entity Framework Core to Workbook with Multiple Sheets

This sample queries a particular "region's" data out of a database with Entity Framework Core and generates a multi-worksheet workbook from the data, including a sheet for each quarter of sales for a list of products as well as a summary sheet for all sales across all quarters. Many other useful APIs are demonstrated during this process.

SQL DataTable to Workbook

This sample queries data into a DataTable from SQLite and copies it into an Excel workbook using IRange.CopyFromDataTable(...)..

SQL DataTable to Template Workbook

This sample queries data into a DataTable from SQLite and copies it into a preformatted range from an existing Excel workbook template using IRange.CopyFromDataTable(...).