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

2023-03-04

导出效果

 

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

添加教程

 

1、\dede\templets\diy_main.htm 找到

前台预览

 

在它的下面加入一行

| 导出表单Excel

 

2、\dede\diy_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 "";

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

         {

                   echo "

";

         }

         echo "

";

         echo "

";

         $sql = "SELECT * FROM {$diy->table} ORDER BY id DESC";

         $dsql->SetQuery($sql);

         $dsql->Execute('t');

         while($arr = $dsql->GetArray('t'))

         {

                   echo "

";

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

                   {

                            echo "

";

                   }

                   $status = $arr['ifcheck'] == 1 ? '已审核' : '未审核';

                   echo "

";

                   echo "

";

         }

         echo "

{$fielddata[0]} 状态
".$arr[$key]." ".$status."
";

}

 

完成。

非凡技术导航 优秀网址导航免费网站收录 网站地图

本站收录的网站若侵害到您的利益,请联系我们删除处理

Copyright ©2020 Guojiz V 5.5All Rights Reserved.

备案号 )| 452133545|