Home > CMS Tutorial > DEDECMS > How to export dedecms' custom form to excel

How to export dedecms' custom form to excel

藏色散人
Release: 2019-12-14 10:25:31
Original
2462 people have browsed it

How to export dedecms' custom form to excel

dedecmsHow to export a customized form to excel?

Modify 2 files to allow Dreamweaver to customize it Freely export defined forms to Excel tables.

Recommended learning: Dream Weaver cms

Modify the tutorial as follows:

1. \dede\templets\diy_main.htm found

Front desk preview

<a href="diy_list.php?action=excel&diyid={dede:field.diyid/}" target="_blank">导出表单Excel</a>
Copy after login

2. \dede\diy_list.php Find

array(&#39;post&#39;, &#39;list&#39;, &#39;edit&#39;, &#39;check&#39;, &#39;delete&#39;))
Copy after login

and change it to

array(&#39;post&#39;, &#39;list&#39;, &#39;edit&#39;, &#39;check&#39;, &#39;delete&#39;, &#39;excel&#39;))
Copy after login

Continue to find

else
{
    showmsg(&#39;未定义操作&#39;, "-1");
}
Copy after login

in Add

else if($action == &#39;excel&#39;)
{
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename={$diy->name}_".date("Y-m-d").".xls");
$fieldlist = $diy->getFieldList();
echo "<table><tr>";
foreach($fieldlist as $field=>$fielddata)
{
echo "<th>{$fielddata[0]}</th>";
}
echo "<th>状态</th>";
echo "</tr>";
$sql = "SELECT * FROM {$diy->table} ORDER BY id DESC";
$dsql->SetQuery($sql);
$dsql->Execute(&#39;t&#39;);
while($arr = $dsql->GetArray(&#39;t&#39;))
{
echo "<tr>";
foreach($fieldlist as $key => $field)
{
echo "<td>".$arr[$key]."</td>";
}
$status = $arr[&#39;ifcheck&#39;] == 1 ? &#39;已审核&#39; : &#39;未审核&#39;;
echo "<td>".$status."</td>";
echo "</tr>";
}
echo "</table>";
}
Copy after login
to it

The above is the detailed content of How to export dedecms' custom form to excel. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template