I have a webpage which the user can manipulate (sorting/filtering) and I want the user to have the option to download the tables.
This is in a jsp file. Currently I can resubmit the page and pass in a value so I know to save it as xls and based on that value I can set the content type to that of a excel file.
response.setContentType(“application/vnd.ms-excel”);
I would like to save the page without resubmitting the page.
What I thought might work was creating a new window and setting the http header’s context type on the window I just opened to that of a excel file. But it seems to have no effect on the page and just loads in the window.
This is my function I am calling.. Am I doing something wrong? Or is my logic just flawed and this wont work.
function save()
{
var generator=window.open(”,’name’,’height=400,width=500′);
generator.document.write(‘<html><head><title>Popup</title>’);
generator.document.write(‘<meta http-equiv=”Content-Type” content=”application/vnd.ms-excel”>’);
generator.document.write(‘<meta http-equiv=”Content-Disposition” content=”attachment; filename=Export.xls;”>’);
generator.document.write(‘<link rel=”stylesheet” href=”style.css”>’);
generator.document.write(‘</head><body>’);
generator.document.write(‘<p>This page was generated by the main window.</p>’);
generator.document.write(‘</body></html>’);
generator.document.close();
}
Thanks