I have done the DataTable to Excel conversion with the following code. Hope it's very easy no need to change more just copy & pest the code replace your variable with your variable, and it will work properly. First create a folder in your solution Document, and create an Excel file MyTemplate.xlsx. you can change those name according to your requirement. But remember for that you have to change the name in code also. Please find the following code...
This code you just need to copy & pest in your script and add the Namespace as following, Also change the excel file name as previously discussed. |