export.php 3.21 KB
<?php

header('Content-Type: application/vnd.ms-excel;charset=utf-8');
$title = iconv('UTF-8','GBK','批次统计');
$name = $title . ".xls";
header('Content-Disposition: attachment;filename=' . $name . '');
header('Cache-Control: max-age=0');
$fp = fopen('php://output', 'a');
$limit = 10000;
$cnt = 0;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:o="urn:schemas-microsoft-com:office:office"
      xmlns:x="urn:schemas-microsoft-com:office:excel"
      xmlns="http://www.w3.org/TR/REC-html40">

<head>
    <meta http-equiv=Content-Type content="text/html; charset=utf-8">

</head>
<body>
<div id="Classeur1_16681" align='center' x:publishsource="Excel">
    <table x:str border='1' cellpadding='0' cellspacing='0' width='100%' style="border-collapse: collapse">
        <thead>
        <tr>
            <th width="9%">编码</th>
            <th width="9%">厂商</th>
            <th width="8%">项目</th>
            <th width="8%">型号</th>
            <th width="8%">生产日期</th>
            <th width="7%">预 | 总生成</th>
            <th width="7%">已删除</th>
            <th width="7%">已授权</th>
            <th width="7%">未授权</th>
            <th width="7%">授权失败(超出)</th>
            <th width="7%">已处理(超出)</th>
            <th width="7%">授权失败(系统)</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach ($listdata as $key => $item) : ?>
            <tr>
                <td style="padding:12px;"><?= (isset($item["batch_no"]) ? $item["batch_no"] : "") ?></td>
                <td style="padding:12px;"><?= (isset($item["manufacture_name"]) ? $item["manufacture_name"] : "") ?></td>
                <td style="padding:12px;"><?= (isset($item["project_name"]) ? $item["project_name"] : "") ?></td>
                <td style="padding:12px;"><?= (isset($item["model_name"]) ? $item["model_name"] : "") ?></td>
                <td style="padding:12px;"><?= (isset($item["production_name"]) ? $item["production_name"] : "") ?></td>
                <td style="padding:12px;"><?= (isset($item["num"]) ? $item["num"] : "0") ?>|<?= (isset($item["total_num"]) ? $item["total_num"] : "0") ?></td>
                <td style="padding:12px;"><?= (isset($item["del_num"]) ? $item["del_num"] : "0") ?></td>
                <td style="padding:12px;"><?= (isset($item["has_auth_num"]) ? $item["has_auth_num"] : "0") ?></td>
                <td style="padding:12px;"><?= (!empty($item["no_auth_num"]) ? $item["no_auth_num"] : "0") ?></td>
                <td><?= (isset($item["out_of_num"]) ? $item["out_of_num"] : "0") ?></td>
                <td style="padding:12px;"><?= (!empty($item["handle_auth_fail_num"]) ? $item["handle_auth_fail_num"] : "0") ?></td>
                <td style="padding:12px;"><?= (!empty($item["auth_fail_num"]) ? $item["auth_fail_num"] : "0") ?></td>
            </tr>
            <?php
            $cnt++;
            if (1000 == $cnt) { //刷新一下输出buffer,防止由于数据过多造成问题
                ob_flush();
                flush();
                $cnt = 0;
            }
            ?>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>
</body>
</html>