您现在的位置是:首页 > cms教程 > DedeCMS教程DedeCMS教程

dedecms自定义表单导出为excel功能的修改方法

石和革2023-09-15DedeCMS教程已有人查阅

导读1、首先在后台修改/dede/templets/diy_main.htm;2、核心内容修改 plus/diy.php再在之后一行下面新加代码:当然,下面输出表头的判断语句你可以自己改!

1、首先在后台修改/dede/templets/diy_main.htm
<a href="../plus/diy.php?action=daochu&diyid={dede:field.diyid/}" target="_blank">导出为EXCEL</a>
修改,后台效果:
2、核心内容修改 plus/diy.php
$action = isset($action) && in_array($action, array('post', 'list', 'view')) ? $action : 'post';
替换成:
$action = isset($action) && in_array($action, array('post', 'list', 'view', 'daochu')) ? $action : 'post';
再在之后一行下面新加代码:
当然,下面输出表头的判断语句你可以自己改!
else if($action == 'daochu')
{
header("Content-type:application/vnd.ms-excel");
Header("Content-Disposition:attachment;filename={$diy->table}_".date("Y-m-d").".xls");   
$query = "desc `{$diy->table}`";
$res = mysql_query($query);
echo "<table><tr>";
//导出表头(也就是表中拥有的字段)
while($row = mysql_fetch_array($res)){
  $t_field[] = $row['Field']; //Field中的F要大写,否则没有结果
/*   echo "<th>".$row['Field']."</th>"; */
        if($row['Field']=='id'){
            echo "<th>ID</th>";
        }elseif($row['Field']=='zhaiwutype'){
            echo "<th>债务类型</th>";
        }elseif($row['Field']=='zhaiquanfang'){
            echo "<th>债权方</th>";
        }elseif($row['Field']=='name'){
            echo "<th>名称</th>";
        }elseif($row['Field']=='jigouhaoma'){
            echo "<th>身份证号/机构代码</th>";
        }elseif($row['Field']=='path'){
            echo "<th>住址/地址</th>";
        }elseif($row['Field']=='tel'){
            echo "<th>联系电话</th>";
        }elseif($row['Field']=='zhaiwufang'){
            echo "<th>债务方</th>";
        }elseif($row['Field']=='zhaiwufangname'){
            echo "<th>债务方名称</th>";
        }elseif($row['Field']=='zhaiwufanghaoma'){
            echo "<th>债务方身份证号/机构代码</th>";
        }elseif($row['Field']=='zhaiwufangpath'){
            echo "<th>债务方地址</th>";
        }elseif($row['Field']=='zhaiwufangtel'){
            echo "<th>债务方电话</th>";
        }elseif($row['Field']=='danbaofang1'){
            echo "<th>担保方</th>";
        }elseif($row['Field']=='danbao1name'){
            echo "<th>担保方名称</th>";
        }elseif($row['Field']=='danbao1haoma'){
            echo "<th>身份证号/机构代码</th>";
        }elseif($row['Field']=='danbao1tel'){
            echo "<th>联系电话</th>";
        }elseif($row['Field']=='zhaiwushuoming'){
            echo "<th>债务说明</th>";
        }elseif($row['Field']=='fayuanzhixing'){
            echo "<th> 是否强制执行</th>";
        }elseif($row['Field']=='zhixingfayuan'){
            echo "<th>执行 </th>";
        }elseif($row['Field']=='lianxiren'){
            echo "<th>联系人</th>";
        }elseif($row['Field']=='lianxidianhua'){
            echo "<th>电话</th>";
        }elseif($row['Field']=='zhaiwujine'){
            echo "<th>债务金额</th>";
        }elseif($row['Field']=='nativeplace1'){
            echo "<th>住址/地址</th>";
        }elseif($row['Field']=='jiamengtype'){
            echo "<th>加入类型</th>";
        }elseif($row['Field']=='groupname'){
            echo "<th>公司(机构)名称</th>";
        }elseif($row['Field']=='grouppath'){
            echo "<th>公司地址</th>";
        }elseif($row['Field']=='groupjianjie'){
            echo "<th>公司简介</th>";
        }elseif($row['Field']=='lianxiren'){
            echo "<th>联系人</th>";
        }elseif($row['Field']=='lianxitel'){
            echo "<th>联系电话</th>";
        }elseif($row['Field']=='lianximobile'){
            echo "<th>手机</th>";
        }elseif($row['Field']=='qq'){
            echo "<th>QQ</th>";
        }elseif($row['Field']=='name'){
            echo "<th>姓名</th>";
        }elseif($row['Field']=='xingbie'){
            echo "<th>性别</th>";
        }elseif($row['Field']=='nianling'){
            echo "<th>年龄</th>";
        }elseif($row['Field']=='danwei'){
            echo "<th>工作单位</th>";
        }elseif($row['Field']=='zhiwu'){
            echo "<th>职务</th>";
        }elseif($row['Field']=='dianhua'){
            echo "<th>联系电话</th>";
        }elseif($row['Field']=='mobile'){
            echo "<th>手机</th>";
        }elseif($row['Field']=='mail'){
            echo "<th>E-mail</th>";
        }elseif($row['Field']=='ifcheck'){
            echo "<th>  </th>";
        }else{
            echo "<th>  </th>";
        }
}
echo "</tr>";
//导出数据
$sql = "select * from `{$diy->table}`";
$res = mysql_query($sql);
while($row = mysql_fetch_array($res)){
  echo "<tr>";
    foreach($t_field as $f_key){
        echo "<td>".$row[$f_key]."</td>";
    }
  echo "</tr>";
}
echo "</table>";
}

本文标签:

很赞哦! ()

相关源码

  • WordPress个人博客主题 - wp-Concise-v1.0免费下载wp-Concise-v1.0是一款专为个人博客设计的简约风格主题,采用全宽排版设计理念,注重内容呈现效果。该模板适用于个人随笔、技术分享、生活记录等博客场景,帮助用户打造专业的内容展示空间。查看源码
  • 自适应建材瓷砖卫浴大理石类pbootcms网站模板源码下载为建材瓷砖、卫浴瓷砖企业打造的高端响应式门户模板,基于PbootCMS内核深度开发。采用前沿HTML5自适应架构,无缝兼容手机端触控交互与PC端展示场景。查看源码
  • (自适应响应式)环保水净化处理设备阀门等网站源码下载基于PbootCMS内核开发的响应式模板,为水处理设备、空气净化器等环保企业设计,自适应手机端浏览。通过简洁高效的后台管理系统,助力环保科技企业快速建立专业在线展示平台。查看源码
  • pbootcms网站网络公司个人作品展示类网站源码(自适应)为网站建设公司、网络服务企业打造的响应式门户解决方案,基于PbootCMS内核深度开发。采用前沿自适应架构,无缝适配手机端交互与PC端展示需求。查看源码
  • 帝国cms自适应古诗词古籍名句网站整站带数据基于帝国CMS打造的专业古诗词文化网站模板,专注于古典文学内容的展示与传播。模板设计蕴含传统文化韵味,支持诗词鉴赏、名句赏析、古籍整理等特色功能,为诗词爱好者提供优质的在线阅读体验。查看源码
  • (PC+WAP)蓝色新能源环保太阳能光伏模板pbootcms下载新能源环保行业网站解决方案为太阳能光伏系统企业打造的专业网站模板,助力新能源企业高效展示产品与服务PbootCMS内核开发,源码开放可修改PC与手机端自适应设计查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐