Exporting data into Excel is a common requirement. In this article, I will explain the exportation of data into Excel in a pre-defined Excel template.
For exporting data into a pre-defined Excel sheet, we will create an Excel sheet (as in the following) in the folder "ExcelTemplates" with the file name "Reports-ProductDetails.xls":
Create a table called Product:
- CREATE TABLE[dbo]. [Product](
- [product_id][int] IDENTITY(1, 1) NOT NULL,
- [product_name][nvarchar](max) NULL,
- [product_rate][money] NULL
- ) ON[PRIMARY] TEXTIMAGE_ON[PRIMARY]
- GO;
Added some records:
Page design code:
After exporting the data into Excel, the report looks like this:
Happy coding!