{"id":30332,"date":"2024-11-25T17:12:49","date_gmt":"2024-11-25T09:12:49","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30332\/"},"modified":"2024-11-25T17:12:49","modified_gmt":"2024-11-25T09:12:49","slug":"dedecms%e7%bb%87%e6%a2%a6%e6%80%8e%e4%b9%88%e8%87%aa%e5%ae%9a%e4%b9%89%e8%a1%a8%e5%8d%95%e5%af%bc%e5%87%ba%e5%88%b0excel","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30332\/","title":{"rendered":"dedecms\u7ec7\u68a6\u600e\u4e48\u81ea\u5b9a\u4e49\u8868\u5355\u5bfc\u51fa\u5230excel"},"content":{"rendered":"<p style=\"text-align: center\"><strong><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5df4481023e48919.jpg\" class=\"aligncenter\" title=\"dedecms\u7ec7\u68a6\u600e\u4e48\u81ea\u5b9a\u4e49\u8868\u5355\u5bfc\u51fa\u5230excel\u63d2\u56fe\" alt=\"dedecms\u7ec7\u68a6\u600e\u4e48\u81ea\u5b9a\u4e49\u8868\u5355\u5bfc\u51fa\u5230excel\u63d2\u56fe\" \/><\/strong><\/p>\n<p><strong>\u7ec7\u68a6\u600e\u4e48\u81ea\u5b9a\u4e49\u8868\u5355\u5bfc\u51fa\u5230excel?<\/strong><\/p>\n<p>\u4fee\u65392\u4e2a\u6587\u4ef6\uff0c\u8ba9\u7ec7\u68a6\u81ea\u5b9a\u4e49\u8868\u5355\u81ea\u7531\u5bfc\u51fa\u5230Excel\u8868\u683c\u91cc\u3002<\/p>\n<p>\u63a8\u8350\u5b66\u4e60\uff1a<\/p>\n<p>\u4fee\u6539\u6559\u7a0b\u5982\u4e0b\uff1a<\/p>\n<p>1\u3001dede empletsdiy_main.htm \u627e\u5230<\/p>\n<p>\u524d\u53f0\u9884\u89c8<\/p>\n<pre>&lt;a&gt;\u5bfc\u51fa\u8868\u5355Excel&lt;\/a&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>2\u3001dedediy_list.php \u627e\u5230<\/p>\n<pre>array('post',&nbsp;'list',&nbsp;'edit',&nbsp;'check',&nbsp;'delete'))<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6539\u6210<\/p>\n<pre>array('post',&nbsp;'list',&nbsp;'edit',&nbsp;'check',&nbsp;'delete',&nbsp;'excel'))<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7ee7\u7eed\u627e\u5230<\/p>\n<pre>else\n{\n&nbsp;&nbsp;&nbsp;&nbsp;showmsg('\u672a\u5b9a\u4e49\u64cd\u4f5c',&nbsp;\"-1\");\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u5b83\u7684\u4e0a\u9762\u52a0\u5165<\/p>\n<pre>else&nbsp;if($action&nbsp;==&nbsp;'excel')\n{\nheader(\"Content-type:application\/vnd.ms-excel\");\nheader(\"Content-Disposition:attachment;filename={$diy-&amp;gt;name}_\".date(\"Y-m-d\").\".xls\");\n$fieldlist&nbsp;=&nbsp;$diy-&amp;gt;getFieldList();\necho&nbsp;\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<table>\n<tbody>\n<tr>\n    &#8220;; foreach($fieldlist&nbsp;as&nbsp;$field=&gt;$fielddata) { echo&nbsp;&#8221; <\/p>\n<th>{$fielddata[0]}<\/th>\n<p>&#8220;; } echo&nbsp;&#8221; <\/p>\n<th>\u72b6\u6001<\/th>\n<p>&#8220;; echo&nbsp;&#8221;<br \/>\n  <\/tr>\n<p>&#8220;; $sql&nbsp;=&nbsp;&#8220;SELECT&nbsp;*&nbsp;FROM&nbsp;{$diy-&gt;table}&nbsp;ORDER&nbsp;BY&nbsp;id&nbsp;DESC&#8221;; $dsql-&gt;SetQuery($sql); $dsql-&gt;Execute(&#8216;t&#8217;); while($arr&nbsp;=&nbsp;$dsql-&gt;GetArray(&#8216;t&#8217;)) { echo&nbsp;&#8221; <\/p>\n<tr>\n    &#8220;; foreach($fieldlist&nbsp;as&nbsp;$key&nbsp;=&gt;&nbsp;$field) { echo&nbsp;&#8221; <\/p>\n<td>&#8220;.$arr[$key].&#8221;<\/td>\n<p>&#8220;; } $status&nbsp;=&nbsp;$arr[&#8216;ifcheck&#8217;]&nbsp;==&nbsp;1&nbsp;?&nbsp;&#8216;\u5df2\u5ba1\u6838&#8217;&nbsp;:&nbsp;&#8216;\u672a\u5ba1\u6838&#8217;; echo&nbsp;&#8221; <\/p>\n<td>&#8220;.$status.&#8221;<\/td>\n<p>&#8220;; echo&nbsp;&#8221;<br \/>\n  <\/tr>\n<p>&#8220;; } echo&nbsp;&#8221;<br \/>\n <\/tbody>\n<\/table>\n<p>&#8220;; } <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u7ec7\u68a6\u600e\u4e48\u81ea\u5b9a\u4e49\u8868\u5355\u5bfc\u51fa\u5230excel\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ec7\u68a6\u600e\u4e48\u81ea\u5b9a\u4e49\u8868\u5355\u5bfc\u51fa\u5230excel? \u4fee\u65392\u4e2a\u6587\u4ef6\uff0c\u8ba9\u7ec7\u68a6\u81ea\u5b9a\u4e49\u8868\u5355\u81ea\u7531\u5bfc\u51fa\u5230Excel\u8868\u683c\u91cc\u3002 \u63a8\u8350\u5b66\u4e60\uff1a \u4fee\u6539\u6559\u7a0b\u5982\u4e0b\uff1a 1\u3001dede empletsdiy_main.htm \u627e\u5230 \u524d\u53f0\u9884\u89c8 &lt;a&gt;\u5bfc\u51fa\u8868\u5355Excel&lt;\/a&gt; \u767b\u5f55\u540e\u590d\u5236 2\u3001dedediy_list.php \u627e\u5230 array(&#8216;post&#8217;,&nbsp;&#8216;list&#8217;,&nbsp;&#8216;edit&#8217;,&nbsp;&#8216;check&#8217;,&nbsp;&#8216;delete&#8217;)) \u767b\u5f55\u540e\u590d\u5236 \u6539\u6210 array(&#8216;post&#8217;,&nbsp;&#8216;list&#8217;,&nbsp;&#8216;edit&#8217;,&nbsp;&#8216;check&#8217;,&nbsp;&#8216;delete&#8217;,&nbsp;&#8216;excel&#8217;)) \u767b\u5f55\u540e\u590d\u5236 \u7ee7\u7eed\u627e\u5230 else { &nbsp;&nbsp;&nbsp;&nbsp;showmsg(&#8216;\u672a\u5b9a\u4e49\u64cd\u4f5c&#8217;,&nbsp;&#8220;-1&#8221;); } \u767b\u5f55\u540e\u590d\u5236 \u5728\u5b83\u7684\u4e0a\u9762\u52a0\u5165 else&nbsp;if($action&nbsp;==&nbsp;&#8216;excel&#8217;) { header(&#8220;Content-type:application\/vnd.ms-excel&#8221;); header(&#8220;Content-Disposition:attachment;filename={$diy-&amp;gt;name}_&#8221;.date(&#8220;Y-m-d&#8221;).&#8221;.xls&#8221;); $fieldlist&nbsp;=&nbsp;$diy-&amp;gt;getFieldList(); echo&nbsp;&#8221; \u767b\u5f55\u540e\u590d\u5236 &#8220;; foreach($fieldlist&nbsp;as&nbsp;$field=&gt;$fielddata) { echo&nbsp;&#8221; {$fielddata[0]} &#8220;; } echo&nbsp;&#8221; \u72b6\u6001 &#8220;; echo&nbsp;&#8221; &#8220;; $sql&nbsp;=&nbsp;&#8220;SELECT&nbsp;*&nbsp;FROM&nbsp;{$diy-&gt;table}&nbsp;ORDER&nbsp;BY&nbsp;id&nbsp;DESC&#8221;; $dsql-&gt;SetQuery($sql); $dsql-&gt;Execute(&#8216;t&#8217;); while($arr&nbsp;=&nbsp;$dsql-&gt;GetArray(&#8216;t&#8217;)) { echo&nbsp;&#8221; &#8220;; foreach($fieldlist&nbsp;as&nbsp;$key&nbsp;=&gt;&nbsp;$field) { echo&nbsp;&#8221; &#8220;.$arr[$key].&#8221; &#8220;; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-30332","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=30332"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30332\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}