Usually, we recommend to create business process for this purpose. It `s more convenient to develop and maintain it later. To generate excel file you can use "EPPlus" library which is frequently updated and comes under the GNU public license. There are some useful links below, please check it.