<a href="../plus/diy.php?action=list&diyid={dede:field.diyid/}" target="_blank"><img src='images/gtk-tmp.png' title='預(yù)覽' alt='預(yù)覽' />前臺預(yù)覽</a>
在后面加上:
| <a href='diy_list.php?action=excel&diyid={dede:field.diyid/}' target="_blank">導(dǎo)出表單Excel</a>
2 修改 dede/diy_list.php,在其中搜索:
$action = isset($action) && in_array($action, array('post', 'list', 'edit', 'check', 'delete')) ? $action : '';
修改為:
$action = isset($action) && in_array($action, array('post', 'list', 'edit', 'check', 'delete','excel')) ? $action : '';
在最底部 大約223行出
else
{
showmsg('未定義操作', "-1");
}
在他前面添加:
elseif($action == 'excel')
{
ob_end_clean();//清除緩沖區(qū),避免亂碼
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename={$diy->name}_".date("Y-m-d").".xls");
print(chr(0xEF).chr(0xBB).chr(0xBF));//清除bom
$fieldlist = $diy->getFieldList();
echo "<table><tr>";
foreach($fieldlist as $field=>$fielddata)
{
echo "<th>{$fielddata[0]}</th>";
}
echo "<th>狀態(tài)</th>";
echo "</tr>";
$sql = "SELECT * FROM {$diy->table} ORDER BY id DESC";
$dsql->SetQuery($sql);
$dsql->Execute('t');
while($arr = $dsql->GetArray('t'))
{
echo "<tr>";
foreach($fieldlist as $key => $field)
{
echo "<td>".$arr[$key]."</td>";
}
$status = $arr['ifcheck'] == 1 ? '已審核' : '未審核';
echo "<td>".$status."</td>";
echo "</tr>";
}
echo "</table>";
}
后臺-更新下緩存 版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請注明: 織夢cms自定義表單導(dǎo)出EXCEL的方法