上海SEO
时光静好,与君语;细水流年,与君同;繁华落尽,与君老...

织梦技巧>正文

织梦dedecms自定义表单导出到excel教程

2019-08-24 09:31 gbl
导出效果

织梦dedecms自定义表单导出到excel教程

 

不写死任何字段,不写死任何东西,修改2个文件,让织梦自定义表单自由导出到Excel表格里。

添加教程

 

1、dede empletsdiy_main.htm 找到

前台预览</a>

 

在它的下面加入一行

<a href=http://www.dede58.com/a/dedejq/"diy_list.php?action=excel&diyid={dede:field.diyid/}" target="_blank">导出表单Excel

 

2、dedediy_list.php 找到

else

{

    showmsg('未定义操作', "-1");

}

 

在它的上面加入

else if($action == 'excel')

{

         header("Content-type:application/vnd.ms-excel");

         header("Content-Disposition:attachment;filename={$diy->name}_".date("Y-m-d").".xls");

         $fieldlist = $diy->getFieldList();

         echo "<table><tr>";

         foreach($fieldlist as $field=>$fielddata)

         {

                   echo "<th>{$fielddata[0]}</th>";

         }

         echo "<th>状态</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>";

}

 

完成。


本文链接:https://www.0937.biz/post-1172.html

图文推荐
热门标签