Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从html表格导出到excel excel公式不起作用_Javascript_Jquery_Excel Formula_Export To Excel - Fatal编程技术网

Javascript 从html表格导出到excel excel公式不起作用

Javascript 从html表格导出到excel excel公式不起作用,javascript,jquery,excel-formula,export-to-excel,Javascript,Jquery,Excel Formula,Export To Excel,我有下面的代码从HTML表格导出excel。我的问题是,导出文件后,当用户添加excel公式进行计算时,excel公式不起作用 我在谷歌上搜索了3天,但当我添加另外2个单元格时没有成功 配方很好用。但是 导出的数据单元公式不起作用 当我添加=SUM(D2,D3)不工作时的示例。有人帮我吗 这个 函数ExportoExcel(){ var tab_text=“”; var textRange;var j=0; tab=document.getElementById('printtable');/

我有下面的代码从HTML表格导出excel。我的问题是,导出文件后,当用户添加excel公式进行计算时,excel公式不起作用

我在谷歌上搜索了3天,但当我添加另外2个单元格时没有成功 配方很好用。但是 导出的数据单元公式不起作用

当我添加
=SUM(D2,D3)
不工作时的示例。有人帮我吗 这个

函数ExportoExcel(){
var tab_text=“”;
var textRange;var j=0;
tab=document.getElementById('printtable');//表的id
对于(j=0;jtab_text=tab_text.replace(/

它是如何工作的?如果它只是显示公式而没有计算,那么单元格可以格式化为文本。如果您收到实际的错误消息,则在导出文件后会发生其他事情。当用户在excel文件中添加公式时。这不起作用
   function ExportoExcel() {
        var tab_text = "<table border='2px'><tr bgcolor='#87AFC6'>";
        var textRange; var j = 0;
        tab = document.getElementById('printtable'); // 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);
    }