I am getting data from my database and I want to have that data as a table in excel file. So, I have written the following :
Dim sheetToPopulate As Excel
Look at something like EPlus which seems to be a popular library.
... or FileHelpers, where there is a good quickstart showing you how to create a .csv file
You can just use the export functionality of Sql Server Management studio if it's a one off type job?