娃儿子 發表於 2023-7-13 00:00:00

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(&#39;post&#39;,&nbsp;&#39;list&#39;,&nbsp;&#39;edit&#39;,&nbsp;&#39;check&#39;,&nbsp;&#39;delete&#39;))</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(&#39;post&#39;,&nbsp;&#39;list&#39;,&nbsp;&#39;edit&#39;,&nbsp;&#39;check&#39;,&nbsp;&#39;delete&#39;,&nbsp;&#39;excel&#39;))</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
{
&nbsp;&nbsp;&nbsp;&nbsp;showmsg(&#39;未定义操作&#39;,&nbsp;&quot;-1&quot;);
}</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&nbsp;if($action&nbsp;==&nbsp;&#39;excel&#39;)
{
header(&quot;Content-type:application/vnd.ms-excel&quot;);
header(&quot;Content-Disposition:attachment;filename={$diy-&gt;name}_&quot;.date(&quot;Y-m-d&quot;).&quot;.xls&quot;);
$fieldlist&nbsp;=&nbsp;$diy-&gt;getFieldList();
echo&nbsp;&quot;&quot;;
foreach($fieldlist&nbsp;as&nbsp;$field=&gt;$fielddata)
{
echo&nbsp;&quot;{$fielddata}&quot;;
}
echo&nbsp;&quot;状态&quot;;
echo&nbsp;&quot;&quot;;
$sql&nbsp;=&nbsp;&quot;SELECT&nbsp;*&nbsp;FROM&nbsp;{$diy-&gt;table}&nbsp;ORDER&nbsp;BY&nbsp;id&nbsp;DESC&quot;;
$dsql-&gt;SetQuery($sql);
$dsql-&gt;Execute(&#39;t&#39;);
while($arr&nbsp;=&nbsp;$dsql-&gt;GetArray(&#39;t&#39;))
{
echo&nbsp;&quot;&quot;;
foreach($fieldlist&nbsp;as&nbsp;$key&nbsp;=&gt;&nbsp;$field)
{
echo&nbsp;&quot;&quot;.$arr[$key].&quot;&quot;;
}
$status&nbsp;=&nbsp;$arr[&#39;ifcheck&#39;]&nbsp;==&nbsp;1&nbsp;?&nbsp;&#39;已审核&#39;&nbsp;:&nbsp;&#39;未审核&#39;;
echo&nbsp;&quot;&quot;.$status.&quot;&quot;;
echo&nbsp;&quot;&quot;;
}
echo&nbsp;&quot;&quot;;
}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
        以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁: [1]
查看完整版本: dedecms织梦自定义表单导出到excel的方法示例