batch-export.php 2.49 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="10%">批次编码</th>
            <th width="15%">序列号</th>
            <th width="12%">MAC地址</th>
            <th width="10%">设备ID</th>
            <th width="10%">申请时间</th>
            <th width="10%">授权时间</th>
            <th width="10%">状态</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach ($deviceList as $key => $item) : ?>
            <tr>
                <td class="td-cls">
                    <?= $item['batch_no'] ?>
                </td>
                <td class="td-cls">
                    <div class="cell-cls"><?= $item['serial_no'] ?></div>
                </td>
                <td class="td-cls">
                    <?= $item['mac'] ?>
                </td>
                <td class="td-cls">
                    <?= $item['device_id']? $item['device_id']:'暂无'?>
                </td>
                <td class="td-cls">
                    <?= $item['apply_at']?date('Y-m-d H:i:s', $item['apply_at']):'暂无' ?>
                </td>
                <td class="td-cls">
                    <?= $item['auth_at']? date('Y-m-d H:i:s', $item['auth_at']):'暂无' ?>
                </td>
                <td class="td-cls">
                    <?= $statusList[$item['status']] ?>
                </td>
            </tr>
            <?php
            $cnt++;
            if (1000 == $cnt) { //刷新一下输出buffer,防止由于数据过多造成问题
                ob_flush();
                flush();
                $cnt = 0;
            }
            ?>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>
</body>
</html>