步骤:
1.打开 /dede/templets/diy_main.htm 大概在第49行的地方加上
意思就是加个导出按钮。
2.打开 /plus/diy.php 在最下面加入以下代码
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',$value)),"\n";}exit;} |
就OK了。
思路很简单,先在列表页搞个可以触发导出的按钮,然后把需要导出的表头和内容查出来,然后以execle输出就好了。 总结
以上是内存溢出为你收集整理的DEDE自定义表单导出功能的实现详细步骤全部内容,希望文章能够帮你解决DEDE自定义表单导出功能的实现详细步骤所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)