Hey Rishu. I'm afraid I don't have a full answer for you, but I just wanted to point out that in the above you're not actually outputting to an Excel file, you're creating a CSV file and both are very different. CSV files are plain text and do not support multiple sheet, so you will need another method for generating a true Excel file.
A quick Google came up with
http://excelbuilderjs.com/ which is a library that should help you generate a true Excel file. Hope that helps.