{"id":230499,"date":"2021-11-26T08:34:49","date_gmt":"2021-11-26T00:34:49","guid":{"rendered":"https:\/\/gulass.cn\/?p=230499"},"modified":"2021-11-19T12:35:57","modified_gmt":"2021-11-19T04:35:57","slug":"python-process-excel","status":"publish","type":"post","link":"https:\/\/gulass.cn\/python-process-excel.html","title":{"rendered":"\u5982\u4f55\u5728 Python \u4e2d\u81ea\u52a8\u5316\u5904\u7406 Excel \u8868\u683c\uff1f"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u8003\u8651\u4e00\u4e2a\u573a\u666f\uff0c\u8981\u6c42\u5728\u7f51\u7ad9\u4e0a\u4e3a 30,000 \u540d\u5458\u5de5\u521b\u5efa\u4e00\u4e2a\u5e10\u6237\u3002\u624b\u52a8\u91cd\u590d\u6267\u884c\u6b64\u4efb\u52a1\u4f1a\u975e\u5e38\u67af\u71e5\u4e4f\u5473\u3002\u6b64\u5916\uff0c\u8fd9\u5c06\u82b1\u8d39\u592a\u591a\u65f6\u95f4\uff0c\u8fd9\u4e0d\u662f\u4e00\u4e2a\u660e\u667a\u7684\u51b3\u5b9a\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u73b0\u5728\u60f3\u8c61\u4e00\u4e0b\u4ece\u4e8b\u6570\u636e\u8f93\u5165\u5de5\u4f5c\u7684\u5458\u5de5\u7684\u751f\u6d3b\u3002\u4ed6\u4eec\u7684\u5de5\u4f5c\u662f\u4ece Excel \u8868\u683c\u4e2d\u83b7\u53d6\u6570\u636e\u5e76\u5c06\u5176\u63d2\u5165\u5176\u4ed6\u4f4d\u7f6e\u3002\u4ed6\u4eec\u6d4f\u89c8\u4e0d\u540c\u7684\u7f51\u7ad9\u548c\u6742\u5fd7\uff0c\u4ece\u90a3\u91cc\u6536\u96c6\u6570\u636e\uff0c\u7136\u540e\u5c06\u5176\u63d2\u5165\u6570\u636e\u5e93\u3002\u4ed6\u4eec\u8fd8\u9700\u8981\u5bf9\u6761\u76ee\u8fdb\u884c\u8ba1\u7b97\u3002<\/p>\n \u4f7f\u7528Python\u81ea\u52a8\u5316\u65e0\u9700\u624b\u52a8\u6267\u884c\u8fd9\u4e9b\u7c7b\u578b\u7684\u4efb\u52a1\uff0c\u53ea\u9700\u82b1\u4e00\u4e2a\u5c0f\u65f6\u5199\u4e00\u6bb5\u4ee3\u7801\u5e76\u81ea\u52a8\u5316\u8fd9\u4e9b\u7c7b\u578b\u7684\u4e8b\u60c5\u3002\u672c\u6587\u4e2d\u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a\u5c0f\u9879\u76ee\u6765\u5b66\u4e60 Python \u4e2d\u7684\u81ea\u52a8\u5316\u3002<\/p>\n \u4efb\u52a1\u4ecb\u7ecd<\/strong><\/div>\n \u624b\u52a8\u5904\u7406\u6216\u66f4\u65b0\u6570\u4ee5\u5343\u8ba1\u7684\u7535\u5b50\u8868\u683c\u5c06\u82b1\u8d39\u592a\u591a\u65f6\u95f4\u3002\u8fd9\u53ef\u80fd\u9700\u8981\u6570\u5c0f\u65f6\u3001\u6570\u5929\u751a\u81f3\u6570\u6708\u7684\u65f6\u95f4\u3002\u6211\u4eec\u5c06\u7f16\u5199\u4e00\u4e2a Python \u7a0b\u5e8f\u6765\u81ea\u52a8\u6267\u884c\u6b64\u4efb\u52a1\u3002\u6211\u4eec\u5c06\u5904\u7406\u4e0b\u56fe\u4e2d\u7ed9\u51fa\u7684\u6570\u636e\u3002 \u6211\u4eec\u5c06\u7f16\u5199\u4e00\u4e2a python \u7a0b\u5e8f\u6765\u81ea\u52a8\u5316\u8fd9\u4e2a\u8fc7\u7a0b\u3002\u6b64\u5916\uff0c\u6211\u4eec\u5c06\u4e3a\u5b83\u6dfb\u52a0\u4e00\u4e2a\u56fe\u8868\u3002\u6211\u4eec\u7684 Python \u7a0b\u5e8f\u5c06\u5728\u51e0\u79d2\u949f\u5185\u4e3a\u6211\u4eec\u5b8c\u6210\u8fd9\u9879\u4efb\u52a1\u3002<\/p>\n \u5199\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7801<\/strong><\/div>\n \u4e3a\u4e86\u5904\u7406\u8fd9\u4e2a Excel \u5de5\u4f5c\u8868\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 \u73b0\u5728\u6211\u4eec\u53ef\u4ee5\u5bfc\u5165\u8fd9\u4e2a\u5305\u6765\u5904\u7406\u6211\u4eec\u7684\u7535\u5b50\u8868\u683c\u3002\u5728\u6b64\u4e4b\u524d\uff0c\u5c06\u7535\u5b50\u8868\u683c\u6dfb\u52a0\u5230\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\u3002\u73b0\u5728\u5728\u4f60\u7684\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6 prod.py \u5e76\u5199\u4e0b\u4e0b\u9762\u7ed9\u51fa\u7684\u4ee3\u7801\u3002<\/p>\n <\/p>\n \u6211\u4eec\u5c06\u9010\u6b65\u89e3\u91ca\u4e0a\u9762\u7f16\u5199\u7684\u4ee3\u7801\u4ee5\u4e86\u89e3\u5b8c\u6574\u7684\u8fc7\u7a0b\u3002<\/p>\n \u6b65\u9aa4 1. \u8981\u5904\u7406\u6211\u4eec\u7684\u7535\u5b50\u8868\u683c\u5bfc\u5165 openpyxl \u5305\uff08\u6211\u4eec\u4f7f\u7528 xl \u522b\u540d\u4f7f\u6211\u4eec\u7684\u4ee3\u7801\u66f4\u7b80\u6d01\u66f4\u77ed\uff09\u3002\u6b64\u5916\uff0c\u8981\u5c06\u56fe\u8868\u6dfb\u52a0\u5230\u6211\u4eec\u7684\u7535\u5b50\u8868\u683c\uff0c\u6211\u4eec\u9700\u8981\u5bfc\u5165\u4e24\u4e2a\u7c7b BarChart \u548c Reference\u3002\u5bfc\u5165time\u5e93\uff0c\u76ee\u7684\u662f\u53e6\u5b58\u8868\u683c\u6587\u4ef6\uff0c\u9632\u6b62\u4fee\u6539\u6e90\u6587\u4ef6\u3002<\/p>\n \u6b65\u9aa42. \u521b\u5efa\u4e00\u4e2a\u51fd\u6570\uff0c\u65b9\u4fbf\u540e\u7eed\u8c03\u7528\u3002<\/p>\n \u6b65\u9aa43. \u73b0\u5728\u6211\u4eec\u9700\u8981\u52a0\u8f7d Excel \u5de5\u4f5c\u7c3f\u3002\u5199\u4e0b\u4e0b\u9762\u7ed9\u51fa\u7684\u4ee3\u7801\u3002tm\u4fdd\u5b58\u5f53\u524d\u65f6\u95f4\uff0c\u4e3a\u540e\u7eed\u4f7f\u7528\u3002wb \u8fd4\u56de\u5bf9\u8c61\uff0c\u4f7f\u7528\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u6211\u4eec\u8bbf\u95ee Sheet1\u5de5\u4f5c\u8868\u3002<\/p>\n \u6b65\u9aa44. \u8981\u8bbf\u95ee\u7b2c\u4e09\u5217\uff08\u4ef7\u683c\u5217\u7684\u6761\u76ee\uff09\u4e2d\u7b2c 2 \u884c\u5230\u6700\u540e\u4e00\u884c\u6709\u6570\u636e\u7684\u6761\u76ee\uff0c\u6211\u4eec\u9700\u8981\u6dfb\u52a0\u4e00\u4e2a for \u5faa\u73af\u3002\u6211\u4eec\u5c06\u6b64\u6761\u76ee\u4fdd\u5b58\u5728\u53ef\u53d8\u5355\u5143\u683c\u4e2d\u3002<\/p>\n \u6b65\u9aa45. \u73b0\u5728\u6211\u4eec\u9700\u8981\u8ba1\u7b97\u4fee\u6b63\u540e\u7684\u4ef7\u683c\u3002\u6240\u4ee5\u6211\u4eec\u5c06\u4fdd\u5b58\u5728\u5355\u5143\u683c\u53d8\u91cf\u4e2d\u7684\u503c\u4e58\u4ee5 0.9\u3002\u8ba1\u7b97\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728\u7b2c 4 \u5217\u4e2d\u6dfb\u52a0\u6240\u6709\u66f4\u6b63\u540e\u7684\u4ef7\u683c\u3002\u6dfb\u52a0\u65b0\u5217\uff0c\u5f15\u7528\u7b2c\u56db\u5217\u7684\u5355\u5143\u683c\u3002\u521b\u5efa\u5355\u5143\u683c\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728\u6b64\u5355\u5143\u683c\u4e2d\u8bbe\u7f6e\u66f4\u6b63\u540e\u7684\u4ef7\u683c\u503c\u3002<\/p>\n \u6b65\u9aa46. \u5de5\u4f5c\u5df2\u7ecf\u5b8c\u6210\u4e86\u4e00\u534a\u3002\u6211\u4eec\u5df2\u7ecf\u8ba1\u7b97\u4e86\u66f4\u65b0\u540e\u7684\u4ef7\u683c\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u7b2c\u56db\u5217\u4e2d\u3002\u73b0\u5728\u6211\u4eec\u9700\u8981\u5411\u5f53\u524d\u5de5\u4f5c\u8868\u6dfb\u52a0\u4e00\u4e2a\u56fe\u8868\u3002\u8981\u521b\u5efa\u56fe\u8868\uff0c\u6211\u4eec\u9700\u8981\u9009\u62e9\u4e00\u4e2a\u503c\u7684\u8303\u56f4\u3002<\/p>\n \u5728\u8fd9\u4e2a\u9879\u76ee\u4e2d\uff0c\u6211\u4eec\u5c06\u9009\u62e9\u7b2c\u56db\u5217\u4e2d\u7684\u503c\uff08\u66f4\u65b0\u540e\u7684\u4ef7\u683c\uff09\uff0c\u6211\u4eec\u5c06\u5728\u6211\u4eec\u7684\u56fe\u8868\u4e2d\u4f7f\u7528\u5b83\uff08\u6211\u4eec\u53ea\u9700\u8981\u4e00\u5806\u6570\u5b57\u6765\u521b\u5efa\u4e00\u4e2a\u56fe\u8868\u3002<\/p>\n \u6211\u4eec\u9700\u8981\u4f7f\u7528 \u6b65\u9aa47. \u73b0\u5728\u6211\u4eec\u5df2\u51c6\u5907\u597d\u521b\u5efa\u56fe\u8868\u3002\u6211\u4eec\u5c06\u4e3a \u6b65\u9aa48. \u73b0\u5728\u6211\u4eec\u9700\u8981\u4fdd\u5b58\u6240\u6709\u66f4\u65b0\u7684\u6761\u76ee\u548c\u6211\u4eec\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\u521b\u5efa\u7684\u56fe\u8868\u3002\u6211\u4eec\u5c06\u628a\u5b83\u4fdd\u5b58\u5728\u4e00\u4e2a\u7528 wb.save(filename + \" \" + tm + '.xlsx')<\/p>\n \u6b65\u9aa49. \u6267\u884c \u8fd0\u884c\u4e0b\u9762\u547d\u4ee4\u4e3a\u811a\u672c\u6dfb\u52a0\u6267\u884c\u6743\u9650\uff0c\u5e76\u6267\u884c\u811a\u672c\uff1a<\/p>\n <\/p>\n \u8fd9\u53ea\u662f\u4f7f\u7528 Python \u81ea\u52a8\u6267\u884c\u91cd\u590d\u6027\u65e0\u804a\u4efb\u52a1\u7684\u4e00\u4e2a\u793a\u4f8b\u3002\u4f46\u8bf7\u8bb0\u4f4f\uff0c\u81ea\u52a8\u5316\u4e0d\u4ec5\u4ec5\u4e0e Excel \u7535\u5b50\u8868\u683c\u6709\u5173\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" \u73b0\u5728\u60f3\u8c61\u4e00\u4e0b\u4ece\u4e8b\u6570\u636e\u8f93\u5165\u5de5\u4f5c\u7684\u5458\u5de5\u7684\u751f\u6d3b\u3002\u4ed6\u4eec\u7684\u5de5\u4f5c\u662f\u4ece Excel \u8868\u683c\u4e2d\u83b7\u53d6\u6570\u636e\u5e76\u5c06\u5176\u63d2\u5165\u5176\u4ed6\u4f4d\u7f6e\u3002\u4ed6\u4eec\u6d4f […]<\/p>\n","protected":false},"author":309,"featured_media":230501,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-230499","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/230499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/309"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=230499"}],"version-history":[{"count":2,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/230499\/revisions"}],"predecessor-version":[{"id":230506,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/230499\/revisions\/230506"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/230501"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=230499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=230499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=230499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}} |