@RNKushwaha: That has nothing to do with the question asked here. If you have a new question, first search this site to see if it's been answered before. If it has not, then post your own new question.
An .xls file is a binary format, not just a .csv file with a different delimiter. (Open one with a hex viewer to see the difference.) The .xls file format is documented in Microsoft Office Excel 97 - 2007 Binary File Format Specification (*.xls 97-2007 format) - note this is a download link to a .xps file, not an HTML page.
How can we generate ans .xls file via php or asp?
If you want Excel to open your file as a CSV file when you double-click it, give it a .csv extension and associate Excel with .csv files (if it isn't already).