{"id":3058,"date":"2024-11-10T12:56:40","date_gmt":"2024-11-10T04:56:40","guid":{"rendered":"https:\/\/fwq.ai\/blog\/3058\/"},"modified":"2024-11-10T12:56:40","modified_gmt":"2024-11-10T04:56:40","slug":"%e5%89%8d%e7%ab%af%e5%a6%82%e4%bd%95%e7%94%a8-javascript-%e5%af%bc%e5%87%ba-excel-%e8%a1%a8%e6%a0%bc%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/3058\/","title":{"rendered":"\u524d\u7aef\u5982\u4f55\u7528 JavaScript \u5bfc\u51fa Excel \u8868\u683c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173098102790447.jpg\" class=\"aligncenter\" title=\"\u524d\u7aef\u5982\u4f55\u7528 JavaScript \u5bfc\u51fa Excel \u8868\u683c\uff1f\u63d2\u56fe\" alt=\"\u524d\u7aef\u5982\u4f55\u7528 JavaScript \u5bfc\u51fa Excel \u8868\u683c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>js \u5bfc\u51fa excel<\/strong><\/p>\n<p>\u60f3\u8981\u5728\u524d\u7aef\u7528 javascript \u5bfc\u51fa excel\uff0c\u9700\u8981\u4f7f\u7528 html \u8868\u683c\u4f5c\u4e3a\u5bfc\u51fa\u6570\u636e\u7684\u57fa\u7840\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 tabletoexcel \u51fd\u6570\u6765\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\u3002\u6b64\u51fd\u6570\u63a5\u6536\u4e09\u4e2a\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>table: \u8981\u5bfc\u51fa\u7684 html \u8868\u683c\u5143\u7d20\u6216\u5176 id<\/li>\n<li>name\uff1a\u5e0c\u671b\u5728 excel \u5de5\u4f5c\u8868\u4e2d\u663e\u793a\u7684\u540d\u79f0\uff08\u53ef\u9009\uff09<\/li>\n<li>filename\uff1a\u5bfc\u51fa\u7684\u6587\u4ef6\u540d\uff08\u53ef\u9009\uff09<\/li>\n<\/ul>\n<p>\u51fd\u6570\u9996\u5148\u5c06 html \u8868\u683c\u8f6c\u6362\u4e3a base64 \u5b57\u7b26\u4e32\uff0c\u7136\u540e\u4f7f\u7528 window.location.href \u5c5e\u6027\u5c06\u5176\u4f5c\u4e3a data url \u4e0b\u8f7d\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u5c06 html \u8868\u683c\u5bfc\u51fa\u4e3a excel \u7684\u57fa\u672c\u539f\u7406\u662f\u5c06\u5176\u653e\u5165\u4e00\u4e2a excel \u5de5\u4f5c\u8868\u4e2d\u3002\u4ee3\u7801\u901a\u8fc7\u521b\u5efa\u4e00\u4e2a\u6a21\u677f html \u6587\u6863\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a\u5360\u4f4d\u7b26 {table}\uff0c\u7528 html \u8868\u683c\u7684\u5185\u5bb9\u66ff\u6362\u3002<\/p>\n<p>\u5982\u679c\u60a8\u60f3\u5728\u4e00\u4e2a excel \u6587\u4ef6\u4e2d\u5305\u542b\u591a\u4e2a\u5de5\u4f5c\u8868\uff0c\u5219\u9700\u8981\u5728\u540e\u53f0\u4f7f\u7528\u670d\u52a1\u5668\u7aef\u8bed\u8a00\uff08\u4f8b\u5982 php \u6216 \uff09\u5c06\u5176\u5408\u5e76\u5728\u4e00\u8d77\u3002<\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u6f14\u793a\u5982\u4f55\u4f7f\u7528 tabletoexcel \u51fd\u6570\u5bfc\u51fa html \u8868\u683c\uff1a<\/p>\n<pre>tableToExcel('myTable', 'My Worksheet', 'my-excel-file.xls');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u5bfc\u81f4\u7528\u6237\u6d4f\u89c8\u5668\u4e0b\u8f7d\u4e00\u4e2a\u540d\u4e3a &#8220;my-excel-file.xls&#8221; \u7684 excel \u6587\u4ef6\uff0c\u5176\u4e2d\u5305\u542b &#8220;mytable&#8221; html \u8868\u683c\u7684\u5185\u5bb9\uff0c\u5e76\u5c06\u5176\u663e\u793a\u5728\u540d\u4e3a &#8220;my worksheet&#8221; \u7684\u5de5\u4f5c\u8868\u4e2d\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u524d\u7aef\u5982\u4f55\u7528 JavaScript \u5bfc\u51fa Excel \u8868\u683c\uff1f\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>js \u5bfc\u51fa excel \u60f3\u8981\u5728\u524d\u7aef\u7528 javascript \u5bfc\u51fa excel\uff0c\u9700\u8981\u4f7f\u7528 html \u8868\u683c\u4f5c\u4e3a\u5bfc\u51fa\u6570\u636e\u7684\u57fa\u7840\u3002 \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 tabletoexcel \u51fd\u6570\u6765\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\u3002\u6b64\u51fd\u6570\u63a5\u6536\u4e09\u4e2a\u53c2\u6570\uff1a table: \u8981\u5bfc\u51fa\u7684 html \u8868\u683c\u5143\u7d20\u6216\u5176 id name\uff1a\u5e0c\u671b\u5728 excel \u5de5\u4f5c\u8868\u4e2d\u663e\u793a\u7684\u540d\u79f0\uff08\u53ef\u9009\uff09 filename\uff1a\u5bfc\u51fa\u7684\u6587\u4ef6\u540d\uff08\u53ef\u9009\uff09 \u51fd\u6570\u9996\u5148\u5c06 html \u8868\u683c\u8f6c\u6362\u4e3a base64 \u5b57\u7b26\u4e32\uff0c\u7136\u540e\u4f7f\u7528 window.location.href \u5c5e\u6027\u5c06\u5176\u4f5c\u4e3a data url \u4e0b\u8f7d\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5c06 html \u8868\u683c\u5bfc\u51fa\u4e3a excel \u7684\u57fa\u672c\u539f\u7406\u662f\u5c06\u5176\u653e\u5165\u4e00\u4e2a excel \u5de5\u4f5c\u8868\u4e2d\u3002\u4ee3\u7801\u901a\u8fc7\u521b\u5efa\u4e00\u4e2a\u6a21\u677f html \u6587\u6863\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a\u5360\u4f4d\u7b26 {table}\uff0c\u7528 html \u8868\u683c\u7684\u5185\u5bb9\u66ff\u6362\u3002 \u5982\u679c\u60a8\u60f3\u5728\u4e00\u4e2a excel \u6587\u4ef6\u4e2d\u5305\u542b\u591a\u4e2a\u5de5\u4f5c\u8868\uff0c\u5219\u9700\u8981\u5728\u540e\u53f0\u4f7f\u7528\u670d\u52a1\u5668\u7aef\u8bed\u8a00\uff08\u4f8b\u5982 php \u6216 \uff09\u5c06\u5176\u5408\u5e76\u5728\u4e00\u8d77\u3002 \u4ee5\u4e0b\u4ee3\u7801\u6f14\u793a\u5982\u4f55\u4f7f\u7528 tabletoexcel \u51fd\u6570\u5bfc\u51fa html \u8868\u683c\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-3058","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3058","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=3058"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3058\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=3058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=3058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=3058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}