Question: how to export sql table data to excel using 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.