If you mean MS office automation, it’s better not to use. There are Considerations for server-side Automation of Office (URL http://support.microsoft.com/kb/257757).
If your excel file will be used for client-side, you can pull data from database and put data to a GridView. Then use GridView.RenderControl to get a grid string (By google Export GridView to Excel, you can get many codes).
Or on server-side, you can use OleDb to deal with Excel file as database. From following URL you can have Connection String for excel:
http://www.connectionstrings.com/?carrier=excel
If your excel file will be used for client-side, you can pull data from database and put data to a GridView. Then use GridView.RenderControl to get a grid string (By google Export GridView to Excel, you can get many codes).
Or on server-side, you can use OleDb to deal with Excel file as database. From following URL you can have Connection String for excel:
http://www.connectionstrings.com/?carrier=excel