I have a classic ASP that I have to update because of changes in Excel(No longer opens tables). In Classic asp, I have recreated my report code to create the data as a string variable containing comma separated values. I need to make that available to download to the customer. I am using a javascript solution that I found on this site. (There is size limitation using Classic ASP to download, not to mention browser compatibility issues).
Here is the Comman seperated string variable:
'Classic ASP
sCSV = Header
sCSV = sCSV & BODY
Here is how I am getting that string variable to the HTML section:
// HTML section
<body>
<input type="hidden" name="sCSV" value="<%=sCSV %>" />
Here is how the customer selects the download and calls the Javascript function:
<p align="left" id="buttonarea">
<a onclick="CSVExport(sCSV)" class="buttonlink">Save Report<br /> as CSV for Excel</a>
</p>
and here is the Javascript function:
// Javascript section
function CSVExport(Source) {
alert(Source);
var csv = Source ;
var downloadLink = document.createElement("a");
var blob = new Blob(["\ufeff", csv]); //Fails at this line
var url = URL.createObjectURL(blob);
downloadLink.href = url;
downloadLink.download = "Report.csv";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
I believe its failing at this line: var blob = new Blob(["\ufeff", csv]);
If I do an alert on sCSV, it says 'Object', which leads me to believe that its not getting a string, but an empty object.
My system will not allow me to use the F12 console to troubleshoot (Its locked out for security). Any help would be appreciated !