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