Create Report in Excel from SQL Server Data
I want to create report in excel using C# .Net from SQL Server Database. If user click a button, then data should be exported to excel from specific table and excel should be displayed in the browser.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mahesh ChandPosted Aug 7, 2008, 6:08 PM
There are two steps to do this and this is the fastest way to do it.
1. You need to get data from the database. Fill it out in a DataGrid, which is not visible on the page.
2. Export DataGrid to Excel.
Here is an article, that gets data from the database, fills in a DataGrid and export it to Excel.
http://www.c-sharpcorner.com/UploadFile/DipalChoksi/ExportASPNetDataGridToExcel11222005041447AM/ExportASPNetDataGridToExcel.aspx
In your code, you have to set DataGrid.Visible = false; to hide your DataGrid.