dedecms织梦自定义表单导出到excel的方法示例
<p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">本文介绍了dedecms织梦自定义表单导出到excel的方法示例,分享给大家,具体如下:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
效果展示:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px;text-align: center;"><span style="color:#428bca"><img style="max-width:100%!important;height:auto!important;" title="dedecms织梦自定义表单导出到excel的方法示例" alt="dedecms织梦自定义表单导出到excel的方法示例" src="https://zhuji.jb51.net/uploads/img/202305/6b0615308951c70af3ffda9bba3df3bc.jpg"/></span></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
修改2个文件,让织梦自定义表单自由导出到Excel表格里。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; "><strong>修改教程如下:</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
1、\dede\templets\diy_main.htm 找到</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
前台预览</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; "><pre class="brush:xhtml;">导出表单Excel</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
2、\dede\diy_list.php 找到</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; "><pre class="brush:php;toolbar:false;">array('post', 'list', 'edit', 'check', 'delete'))</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
改成</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; "><pre class="brush:php;toolbar:false;">array('post', 'list', 'edit', 'check', 'delete', 'excel'))</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
继续找到</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; "><pre class="brush:php;toolbar:false;">else
{
showmsg('未定义操作', "-1");
}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
在它的上面加入</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; "><pre class="brush:php;toolbar:false;">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 "{$fielddata}";
}
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 "".$arr[$key]."";
}
$status = $arr['ifcheck'] == 1 ? '已审核' : '未审核';
echo "".$status."";
echo "";
}
echo "";
}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁:
[1]