I had some data in an HTML table which wanted to be downloadable as a spreadsheet.
Since both excel and open office can read CSV. I am generating a CSV using a PHP script on the server by passing it the data from HTML table using JS.
I was wondering If I could directly open a browser window with that CSV as its conetnt and if could set its content type to CSV, Will this work ? Is there a way to modify content type on the client ?
Server side, you need to have scripts that can generate two different “views” of the same data, the HTML table for viewing online, and the CSV for exporting. Once you have that, it’s just a matter of using window.open in javascript to open a window on the CSV view.