dpa84373 2014-12-07 15:13
浏览 137

Codeigniter编写excel文件

I have the following view file

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<table border="1" align="center">
    <thead>
        <tr>
                <th>TransactionDate</th>
                <th>SettlementRefNo</th>
                <th>TransactionRefNo</th>
                <th>CustomerName</th>
                <th>TransactionAmount</th>
                <th>TDR</th>
                <th>ServiceTax</th>
                <th>FinalSettledAmount</th>
                <th>MerchantName</th>
           </tr>
    </thead>
    <tbody>
            <?php foreach ($success as $row): ?>
            <tr>
                <td><?php echo $row['trans_date'];?></td>
                <td><?php echo $row['settlement_refNo'];?></td>
                <td><?php echo $row['shmart_refID'];?></td>
                <td><?php echo $row['customer_name'];?></td>
                <td><?php echo $row['trans_amount'];?></td>
                <td><?php echo $row['tdr_amount'];?></td>
                <td><?php echo $row['serviceTax_amount'];?></td>
                <td><?php echo $row['final_settled_amount'];?></td>
                <td><?php echo $row['username'];?></td>
            </tr>
            <?php endforeach; ?>
    </tbody>
</table>
</body>
</html>

This is the controller

        $settlement_processed_data['success'] = $this->report_generation_model->get_processed_data();       
        $myFile = FCPATH."admin_process_settlement_files/".date('d-M-Y').".xls";        
        $stringTransData = $this->parser->parse('settlement_processed_xls', $settlement_processed_data, true);
        $fh = fopen($myFile, 'w') or die("can't open file");
        fwrite($fh, $stringTransData);
        fclose($fh);
        $data = file_get_contents("/var/www/html/testingserv/admin/admin_process_settlement_files/".date('d-M-Y').".xls");
        $name="settlements.xls";
        force_download($name, $data);
        unlink($myFile);

What the controller does is,Get the array from the database , and load it into the view and parse the contents,but the content which is been passed has

���������������� ���������������� ���������������� ���������������� ���������������� ���������������� ���������������� ���������������� ���������������� ����������� ���� ��������  ����

and the resulting xls file which is generated is having the in the middle of the excel file.Why is this happening?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡等级和折扣规则
    • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
    • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
    • ¥15 gdf格式的脑电数据如何处理matlab
    • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
    • ¥100 监控抖音用户作品更新可以微信公众号提醒
    • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
    • ¥70 2048小游戏毕设项目
    • ¥20 mysql架构,按照姓名分表
    • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分