exportDa.php 2.15 KB
<?php
use domain\user\User;
    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 style="width:60px">ID</th>
            <th style="width:120px">维修厂名称</th>
            <th style="width:100px">维修厂电话</th>
            <th style="width:100px;">紧急联系人</th>
            <th style="width:100px;">紧急联系电话</th>
            <th style="width:100px">注册时间</th>
            <th style="width:100px;">状态</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach ($listdata as $user) : ?>
            <tr>
                <td class="text-center align-middle hqy-row-select"><?=$user['id'] ?></td>
                <td><?=$user['name']?></td>
                <td><?=$user['mobile']?></td>
                <td><?=$user['emergency_person']?></td>
                <td><?=$user['emergency_contact']?></td>
                <td><?=date('Y-m-d H:i', $user['created_at'])?></td>
                <td><?=User::getStatusLabels($user['status'])?></td>
            </tr>
            <?php
            $cnt++;
            if (1000 == $cnt) { //刷新一下输出buffer,防止由于数据过多造成问题
                ob_flush();
                flush();
                $cnt = 0;
            }
            ?>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>
</body>
</html>