您现在的位置是:首页 > 教程 > dedecms教程dedecms教程
dedecms自定义表单导出为excel功能的修改方法
石和革2023-09-15 23:53:38dedecms教程已有人查阅
导读1、首先在后台修改/dede/templets/diy_main.htm;2、核心内容修改 plus/diy.php再在之后一行下面新加代码:当然,下面输出表头的判断语句你可以自己改!
1、首先在后台修改/dede/templets/diy_main.htm
2、核心内容修改 plus/diy.php
当然,下面输出表头的判断语句你可以自己改!
<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>";
}
本文标签:
很赞哦! ()
相关文章
随机图文
-
Dedecms5.7内容文章tags标签实现带链接URL的方法
我们在使用的时候一般内容文章页调用当前的tag是不带链接的,我们只要加上这么一段,就可以实现调用文章tag关键词都带链接。 -
dedecms中英文网站之中英文搜索结果实现实例
本文实例讲述了dedecms中英文网站之中英文搜索结果实现方法。分享给大家供大家参考。具体实现方法如下: -
怎么批量替换织梦dede所有文章来源和作者
DedeCms使用技巧:如何批量替换文章“来源”和“作者”1.打开DedeCMS网站根目录,找到 \templets\article_add.htm (发表普通模板)和article_edit.htm(修改普通模板)这两个文件,分别把: -
dedecms织梦点击量标签调用方法和介绍
我们已经学习了栏目链接和文章链接,今天我们来学习一下点击量的一些具体的应用。点击量在dede里的调用标签是[field:click/],这是众所周知的。
留言与评论 (共有 条评论) |