0

Similar to: How can I export tables to excel from a webpage.

There is just one little problem. The .xls file is being saved with a random name. But I need to set my own name to the Excel file. Is there any way of doing it?

This is the JavaScript I am using:

window.open('data:application/vnd.ms-excel,'+document.documentElement.innerHTML);
Community
  • 1
  • 1
koushik
  • 55
  • 7

2 Answers2

0

You need server side code for that. Except in chrome you can use <a download="abc.xls" /> attribute

chetan
  • 2,876
  • 1
  • 14
  • 15
0

You can't do this with client-side JavaScript, you need to set the response header...

.NET

Response.AddHeader("Content-Disposition", "inline;filename=filename.xls")

Php

$filename = 'somehting.xls';

header('Content-Disposition: attachment; filename="'.$filename.'"');
Tredged
  • 586
  • 2
  • 17
  • I told you and the beginning of my comment that its not possible with Javascript because you need to set a response header. – Tredged Jul 02 '13 at 10:17