1, first modify /dede/templets/diy_main.htm in the background
<a href="../plus/diy.php?action=daochu&diyid={dede:field.diyid/}" target="_blank">导出为EXCEL</a>
Modification, the background to the following figure:
2, modify the core 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';
Then the new code is added in the last line of the following:
Of course, the following output header judge sentences you can do it ourselves!
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>"; )) { $ RES(the mysql_fetch_array=$ Row(the whilederived header (i.e. fields in the table have)// t_field $ [] = $ Row [ 'Field,']; // Field, F is capitalized, or no result / * echo "<TH>" $ Row [ 'Field,'] "</ TH>";.. * / IF ( $ Row [ 'Field,'] == 'ID' ) { echo "<TH> ID </ TH>" ; } ELSEIF ( $ Row [ 'Field,'] == 'zhaiwutype' ) { echo "<TH > debt type </ th> " ; } ELSEIF ( $ Row [ 'Field,'] == 'zhaiquanfang' ) { echo " <TH> creditor </ th>"; }elseif($row[ 'Field,'] == 'name' ) { echo "<TH> Name </ TH>" ; } ELSEIF ( $ Row [ 'Field,'] == 'jigouhaoma' ) { echo "<TH> ID Number / organization code </ TH> " ; } ELSEIF ( $ Row [ 'Field,'] == 'path' ) { echo " <TH> address / address </ TH> " ; } ELSEIF ( $ Row [ 'Field,'] = = 'Tel' ) { echo "<TH> telephone </ TH>" ; }elseif($row['Field']=='zhaiwufang'){ echo"<th> debtor </ TH>" ; } ELSEIF ( $ Row [ 'Field,'] == 'zhaiwufangname' ) { echo "<th> debtor Title </ TH>" ; } ELSEIF ( $ Row [ ' Field, '] ==' zhaiwufanghaoma ' ) { echo "<TH> ID No. debtor / organization code </ TH>" ; } ELSEIF ( $ Row [' Field, '] ==' zhaiwufangpath ' ) { echo "<TH > debt party address </ TH> " ; } ELSEIF ( $ Row [ 'Field,'] == 'zhaiwufangtel ' ) { echo "<TH> Phone debtor </ TH>" ; } ELSEIF ( $ Row [ 'Field,'] == 'danbaofang1' ) { echo "<TH> sponsor </ TH>" ; } ELSEIF ( $ Row [ 'Field,'] == 'danbao1name' ) { echo "< th> sponsor name </ th> " ; } ELSEIF ( $ Row [ 'Field,'] == 'danbao1haoma' ) { echo " <th> ID number / organization code </ th> " ; } ELSEIF ( $ Row [ 'Field,'] == 'danbao1tel' ) { echo "<th> Telephone </ th> " ; } ELSEIF (Row $ [ 'Field,'] == 'zhaiwushuoming' ) { echo "<TH> Description debt </ TH>" ; } ELSEIF ( $ Row [ 'Field,'] == 'fayuanzhixing' ) { echo "<TH> court whether enforced </ TH> " ; } ELSEIF ( $ Row [ 'Field,'] == 'zhixingfayuan' ) { echo " <TH> Court performed </ TH> " ; } ELSEIF ( $ Row [ 'Field,'] = = 'lianxiren' ) { echo "<TH> contact </ TH>" ; }elseif($row['Field']=='lianxidianhua') { Echo "<TH> Phone </ TH>" ; } ELSEIF ( $ Row [ 'Field,'] == 'zhaiwujine' ) { echo "<TH> debt amount </ TH>" ; } ELSEIF ( $ Row [ 'Field,'] == 'nativeplace1' ) { echo "<TH> address / address </ TH>" ; } ELSEIF ( $ Row [ 'Field,'] == 'jiamengtype' ) { echo "<TH> Add type < / TH> " ; } ELSEIF ( $ Row [ 'Field']=='groupname'){ echo"<th> Company (means) NAME </ TH>" ; } ELSEIF ( $ Row [ 'Field,'] == 'GroupPath' ) { echo "<th> Address </ TH>" ; } ELSEIF ( $ Row [ 'Field,'] == 'groupjianjie' ) { echo "<TH> company </ TH>" ; } ELSEIF ( $ Row [ 'Field,'] == 'lianxiren' ) { echo "<TH> contacts < / TH> " ; } ELSEIF ( $ Row [ 'Field,'] == 'lianxitel') { Echo "<TH> telephone </ 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>"; }