else if($action == 'push') { $row = $dsql->GetOne("Select * From dede_diyforms where diyid='$diyid'"); $ds = file(('/dede/inc/fieldtype.txt')); foreach($ds as $d){ $dds = explode(',',trim($d)); $fieldtypes[$dds[0]] = $dds[1]; } $fieldset = $row['info']; $dtp = new DedeTagParse(); $dtp->SetNameSpace("field","<",">"); $dtp->LoadSource($fieldset); $titleArray=array(); $titleName=array(); if(is_array($dtp->CTags)){ foreach($dtp->CTags as $ctag) { $itname = $ctag->GetAtt('itemname'); if($itname=='') echo "沒指定"; $titleArray[] = $itname; $titleName[]= $ctag->GetTagName(); } } header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment; filename=demo.xls'); header('Pragma: no-cache'); header('Expires: 0'); $title =$titleArray; include_once DEDEINC.'/datalistcp.class.php'; if($diy->public == 2) $query = "SELECT * FROM `{$diy->table}` ORDER BY id DESC"; else $query = "SELECT * FROM `{$diy->table}` WHERE ifcheck=1 ORDER BY id DESC"; $datalist = new DataListCP(); $datalist->pageSize = 10; $datalist->SetParameter('action', 'list'); $datalist->SetParameter('diyid', $diyid); $datalist->SetSource($query); $rsArray = array(); $datalist->dsql->Execute('dlist',$datalist->sourceSql); $i = 0; while($arr=$datalist->dsql->GetArray('dlist')) { $i++; $object = array(); foreach ($titleName as $va){ $object[]=$arr[$va]; } $rsArray[$i] = $object; } $data = $rsArray; echo iconv('utf-8', 'gbk', implode("\t", $title)), "\n"; foreach ($data as $value) { echo iconv('utf-8', 'gbk', implode("\t", $value)), "\n"; } exit; } |
版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: dede 自定義表單導(dǎo)出功能的實(shí)現(xiàn)詳細(xì)步驟