Is there any way to generate Excel/CSV through Javascript? (It should be browser compaatible too)
You can generate whatever you like, but the question is - how are you going to present it to the user? If your JS runs in the browser, you won't be able to make a save-as dialog box or even open it in the same window. Not unless you use some ActiveX controls, but that's an IE-only solution which will also give the user a few confirmation prompts before it starts to work.
Create an AJAX postback method which writes a CSV file to your webserver and returns the url.. Set a hidden IFrame in the browser to the location of the CSV file on the server.
Your user will then be presented with the CSV download link.
It seems to me to be much easier to do on the server side. But I guess you have your reasons. Also, as gmc notes, drop Excel, and generate CSV-files instead. This has the added bonus of being useful for those of your users that do not have Excel installed.
I recommend you to generate an open format XML Excel file, is much more flexible than CSV.
Read http://stackoverflow.com/questions/150339/generating-an-excel-file-in-aspnet for more info
I see no difficulty in generating CSV data, but as pointed out above, what is the point? Will you fill up a textarea?
If so, it is very easy, so you should be more precise: where are you stuck, what kind of data you handle, where will it come from?