'html to excel export'에 해당되는 글 1건

  1. 2018.06.12 chrome, ie html to excel export 1
반응형

function excelExport(){

  exportTable($('#jsGrid').html(), 'myFilename.xls');

}


function exportTable(myTable, filename) {

  var agent = navigator.userAgent.toLowerCase();

  if ( (navigator.appName == 'Netscape' && agent.indexOf('trident') != -1) || (agent.indexOf("msie") != -1)) {

       // ie일 경우

       csvData = myTable;

       if (window.navigator.msSaveBlob) {

           var blob = new Blob([csvData], {

               type: "text/html"

           });

           navigator.msSaveBlob(blob, filename);

       }

  }else{

       // ie가 아닐 경우

       window.open("data:application/vnd.ms-excel," + encodeURIComponent(myTable));

  }

}



Posted by 1010