Question: how to export data from sql database to excel in c#?
Answer: Create a connection with SQL server database by providing proper credential and server and database name.
Create a SqlCommand object to define the SQL Command.
Fill the data adapter with the datatable object values.
Create Excel Application object for exporting the data.
Insert data into Excel Application Worksheet.