Пример #1
0
    $outputFileName = 'data/excel/' . $datename . '.xls';
    $content = array();
    $archive = array("接收人", "发送人", "发送时间", "内容");
    $content[] = $archive;
    $wheresql = '';
    $vuidtype = getGP('vuidtype', 'P');
    if (!is_superadmin() && $vuidtype == '') {
        $wheresql .= " AND uid ='" . $_USER->id . "'";
    }
    if ($vuidtype != '') {
        if ($vuidtype == '-1') {
            $wheresql .= get_subordinate($_USER->id, 'uid');
        } else {
            $wheresql .= " and uid='" . $vuidtype . "'";
        }
    }
    $sql = "SELECT * FROM " . DB_TABLEPRE . "sms_send WHERE 1 {$wheresql} ORDER BY id desc";
    $result = $db->query($sql);
    while ($row = $db->fetch_array($result)) {
        $archive = array("" . $row['receiveperson'] . "", "" . get_realname($row['uid']) . "", "" . str_replace("-", ".", $row[date]) . "", "" . $row['content'] . "");
        $content[] = $archive;
    }
    $excel = new ExcelWriter($outputFileName);
    if ($excel == false) {
        echo $excel->error;
    }
    foreach ($content as $v) {
        $excel->writeLine($v);
    }
    $excel->sendfile($outputFileName);
}