2

How to download table rows in CSV format in Internet Explorer from client side? At present I am using the below URI method to download it in other browser. But it seems Internet Explorer does not support the below mechanism. I want to support from IE version 8 till the latest. Any help for IE would be appreciated.

   var fileName = "Result"; 
   var uri = 'data:text/csv;charset=utf-8,' + escape(CSV);
   var link = document.createElement("a");    
   link.href = uri;
   link.style = "visibility:hidden";
   link.download = fileName + ".csv";
   document.body.appendChild(link);
   link.click();
   document.body.removeChild(link);
1
  • You can't! There's no support for the HTML5 download attribute in older IE, the only way to do this is serverside with the correct headers. Commented Nov 11, 2014 at 5:35

1 Answer 1

1

I got the solution for it which is supporting IE 8+ for me. We need to specify the separator as shown below.

if (navigator.appName == "Microsoft Internet Explorer") {    
    var oWin = window.open();
    oWin.document.write('sep=,\r\n' + CSV);
    oWin.document.close();
    oWin.document.execCommand('SaveAs', true, fileName + ".csv");
    oWin.close();
  }  

You can go through the link http://andrew-b.com/view/article/44

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.