Ceate CSV显示页面无响应的错误

时间:2016-06-22 18:38:03

标签: php jquery mysql codeigniter csv

我从MySQL数据库中获取数据创建CSV。有大约18000行和8列,但它显示我的页面unresponsive error并显示kill pagewait

enter image description here

我使用了以下代码。

function report_print()
{           
    date   = time();
    $myFile = "report_$date.csv";
    $this->load->library('parser');
    $stringData = $this->input->post('data');
    $fileArray  = $this->getdata($stringData);
    $this->generateconvert_to_csv($fileArray, $myFile, ',');
    die;
}

我还尝试使用以下代码创建带有jQuery的CSV,但它显示“网络失败”的错误。

jQuery.fn.tableToCSV = function() {

    var clean_text = function(text){
        text = text.replace(/"/g, '""');
        return '"'+text+'"';
    };

    $(this).each(function(){
            var table = $(this);
            var caption = $(this).find('caption').text();
            var title = [];
            var rows = [];

            $(this).find('tr').each(function(){
                var data = [];
                $(this).find('th').each(function(){
                    var text = clean_text($(this).text());
                    title.push(text);
                    });
                $(this).find('td').each(function(){
                    var text = clean_text($(this).text());
                    data.push(text);
                    });
                data = data.join(",");
                rows.push(data);
                });
            title = title.join(",");
            rows = rows.join("\n");

            var csv = title + rows;
            var uri = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv);
            var download_link = document.createElement('a');
            download_link.href = uri;
            var ts = new Date().getTime();
            if(caption==""){
                download_link.download = ts+".csv";
            } else {
                download_link.download = caption+"-"+ts+".csv";
            }
            document.body.appendChild(download_link);
            download_link.click();
            document.body.removeChild(download_link);
    });

};

对于如何使用这么多记录创建CSV而没有任何问题,任何人的帮助都将受到赞赏?

0 个答案:

没有答案