export.php 2.74 KB
<?php

header('Content-Type: application/vnd.ms-excel;charset=utf-8');
$title = date('Y-m-d') . '_批次统计';
$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 border='1' cellpadding='0' cellspacing='0' width='100%' style="border-collapse: collapse">
        <thead>
        <tr>
            <th width="10%">编码</th>
            <th width="10%">厂商</th>
            <th width="10%">项目</th>
            <th width="10%">型号</th>
            <th width="10%">生产日期</th>
            <th width="10%">生成总数</th>
            <th width="10%">授权总数</th>
            <th width="15%">授权失败数</th>
            <th width="15%">未授权数</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;"><a href="<?=Url::toRoute('datas/device/device-list')?>"><?= (isset($item["num"]) ? $item["num"] : "0") ?></a></td>
                <td style="padding:12px;"><?= (isset($item["has_auth_num"]) ? $item["has_auth_num"] : "0") ?></td>
                <td style="padding:12px;"><?= (!empty($item["auth_fail_num"]) ? $item["auth_fail_num"] : "0") ?></td>
                <td style="padding:12px;"><?= (!empty($item["no_auth_num"]) ? $item["no_auth_num"] : "0") ?></td>
            </tr>
            <?php
            $cnt++;
            if (1000 == $cnt) { //刷新一下输出buffer,防止由于数据过多造成问题
                ob_flush();
                flush();
                $cnt = 0;
            }
            ?>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>
</body>
</html>