Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript leetcode solutions

<iframe id="txtArea1" style="display:none"></iframe>
Comment

javascript leetcode solutions

function fnExcelReport()
{
    var tab_text="<table border='2px'><tr bgcolor='#87AFC6'>";
    var textRange; var j=0;
    tab = document.getElementById('headerTable'); // id of table

    for(j = 0 ; j < tab.rows.length ; j++) 
    {     
        tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";
        //tab_text=tab_text+"</tr>";
    }

    tab_text=tab_text+"</table>";
    tab_text= tab_text.replace(/<A[^>]*>|</A>/g, "");//remove if u want links in your table
    tab_text= tab_text.replace(/<img[^>]*>/gi,""); // remove if u want images in your table
    tab_text= tab_text.replace(/<input[^>]*>|</input>/gi, ""); // reomves input params

    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE "); 

    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv:11./))      // If Internet Explorer
    {
        txtArea1.document.open("txt/html","replace");
        txtArea1.document.write(tab_text);
        txtArea1.document.close();
        txtArea1.focus(); 
        sa=txtArea1.document.execCommand("SaveAs",true,"Say Thanks to Sumit.xls");
    }  
    else                 //other browser not tested on IE 11
        sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));  

    return (sa);
}
Comment

javascript leetcode solutions

<button id="btnExport" onclick="fnExcelReport();"> EXPORT </button>
Comment

javascript leetcode solutions

Call this function on:
<button id="btnExport" onclick="fnExcelReport();"> EXPORT </button>
Comment

javascript leetcode solutions

Just create a blank iframe:
<iframe id="txtArea1" style="display:none"></iframe>
Comment

javascript leetcode solutions

Excel export script works on IE7+, Firefox and Chrome.

function fnExcelReport()
{
    var tab_text="<table border='2px'><tr bgcolor='#87AFC6'>";
    var textRange; var j=0;
    tab = document.getElementById('headerTable'); // id of table

    for(j = 0 ; j < tab.rows.length ; j++) 
    {     
        tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";
        //tab_text=tab_text+"</tr>";
    }

    tab_text=tab_text+"</table>";
    tab_text= tab_text.replace(/<A[^>]*>|</A>/g, "");//remove if u want links in your table
    tab_text= tab_text.replace(/<img[^>]*>/gi,""); // remove if u want images in your table
    tab_text= tab_text.replace(/<input[^>]*>|</input>/gi, ""); // reomves input params

    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE "); 

    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv:11./))      // If Internet Explorer
    {
        txtArea1.document.open("txt/html","replace");
        txtArea1.document.write(tab_text);
        txtArea1.document.close();
        txtArea1.focus(); 
        sa=txtArea1.document.execCommand("SaveAs",true,"Say Thanks to Sumit.xls");
    }  
    else                 //other browser not tested on IE 11
        sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));  

    return (sa);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: fat arrow return object 
Javascript :: auto closing not working jsx 
Javascript :: vue expected string with value got number with value 
Javascript :: default values not applied on findoneandupdate mongoose 
Javascript :: contentful rte edit link type 
Javascript :: javascript loop all depths recursive object 
Javascript :: select value from select and pass it to useeffect 
Javascript :: How to make Jquery Class clickable 
Javascript :: js find selected input 
Javascript :: es6-map-an-array-of-objects-to-return-an-array-of-objects-with-new-keys 
Javascript :: how to reset count in react 
Javascript :: usecase of async/await 
Javascript :: runjs 
Javascript :: start withnreact 
Javascript :: react native controlling device brightness 
Javascript :: native module reactnativepushnotification tried to override rnpushnotification 
Javascript :: react native biometrics sign in 
Javascript :: Message on a kendo loader 
Javascript :: Node_connect 
Javascript :: react google login button size increase 
Javascript :: when reload the page the route gone in react js laravel 
Javascript :: limpar html string js 
Javascript :: Cycle through a list to see if there is a match for the characters entered into an input box 
Javascript :: generate diffrent random array Numbers 
Javascript :: angular number pipe to four decimals 
Javascript :: how to retrieve get parameters from javascript 
Javascript :: js append sample 
Javascript :: saving some fields of an instance in sequelize 
Javascript :: assignment of struct in solidity 
Javascript :: mongoose schema aggregation lookup multiple collections 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =