{"id":186,"date":"2021-10-13T14:45:48","date_gmt":"2021-10-13T06:45:48","guid":{"rendered":"https:\/\/www.lucas88.cn\/?p=186"},"modified":"2021-10-13T14:45:48","modified_gmt":"2021-10-13T06:45:48","slug":"excel%e8%a1%a8%e6%a0%bc%e8%bd%ac%e6%8d%a2%e6%88%90html%e8%a1%a8%e6%a0%bc%e5%b7%a5%e5%85%b7","status":"publish","type":"post","link":"https:\/\/www.lucas88.cn\/?p=186","title":{"rendered":"EXCEL\u8868\u683c\u8f6c\u6362\u6210HTML\u8868\u683c\u5de5\u5177"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-21.png\" alt=\"\" class=\"wp-image-187\" width=\"766\" height=\"234\" srcset=\"https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-21.png 720w, https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-21-300x92.png 300w\" sizes=\"auto, (max-width: 766px) 100vw, 766px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u539f\u8868\u683c\u4e2d\u7b7e\u540d\u4e3a\u8def\u5f84\u4fe1\u606f\uff0c\u65e0\u6cd5\u67e5\u770b\uff01<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-23-1024x256.png\" alt=\"\" class=\"wp-image-189\" width=\"775\" height=\"194\" srcset=\"https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-23-1024x256.png 1024w, https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-23-300x75.png 300w, https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-23-768x192.png 768w, https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-23.png 1418w\" sizes=\"auto, (max-width: 775px) 100vw, 775px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f6c\u6362\u540e\u5c06\u56fe\u7247\u8def\u5f84\u89e3\u6790\u6210\u56fe\u7247\u663e\u793a\u51fa\u6765<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-22-1024x334.png\" alt=\"\" class=\"wp-image-188\" width=\"776\" height=\"252\" srcset=\"https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-22-1024x334.png 1024w, https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-22-300x98.png 300w, https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-22.png 1892w\" sizes=\"auto, (max-width: 776px) 100vw, 776px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u901a\u8fc7ie\u6253\u5f00\u540e\u7528\u865a\u62df\u6253\u5370\u673a\u53ef\u4ee5\u5c06\u9875\u9762\u6253\u5370\u6210pdf\u6587\u6863<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"600\" src=\"https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-24-1024x600.png\" alt=\"\" class=\"wp-image-190\" srcset=\"https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-24-1024x600.png 1024w, https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-24-300x176.png 300w, https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-24-768x450.png 768w, https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/10\/image-24.png 1167w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u6e90\u7801\uff1a<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\n#! python3\n# -*- coding: utf-8 -*-\nimport openpyxl,pprint,os\nimport PySimpleGUI as sg\ndef data_processing():\n    wb = openpyxl.load_workbook(values&#x5B;'-xz1-'])\n    sheet = wb&#x5B;str(wb.sheetnames&#x5B;0])]\n    f_5 = open(values&#x5B;'-xz2-']+'\/\u9879\u76ee\u6570\u636e\u8868.html','a')\n    f_5.write('&lt;!DOCTYPE html&gt;'+&quot;\\n&quot;+'&lt;html&gt;' +&quot;\\n&quot; + '&lt;body&gt;' +&quot;\\n&quot;+ '&lt;table border=&quot;1&quot;&gt;' +&quot;\\n&quot;)\n    for i in range(1,sheet.max_row+1):\n        f_5.write('&lt;tr&gt;'+&quot;\\n&quot;)\n        for c in range(1,sheet.max_column+1):\n            name = sheet.cell(i,c).value\n            if &quot;.png&quot; in  str(name):\n                f_5.write('&lt;th&gt;&lt;img src=&quot;https:\/\/ylwxsb.19wms.com' + str(name) + '&quot; height=&quot;31&quot; width=&quot;90&quot;&gt;&lt;\/th&gt;' + &quot;\\n&quot;)\n            else:\n                f_5.write('&lt;th&gt;' + str(name) + '&lt;\/th&gt;' +&quot;\\n&quot;)\n        f_5.write('&lt;\/tr&gt;'+&quot;\\n&quot;)\n    f_5.write('&lt;\/table&gt;' +&quot;\\n&quot; + '&lt;\/body&gt;' +&quot;\\n&quot;+ '&lt;\/html&gt;' +&quot;\\n&quot;)\n    f_5.close()\nlayout = &#x5B;\n&#x5B;sg.T('\u8868\u683c\u8def\u5f84:',size=(8,1),key='-xm-'),sg.T(' ',size=(40,1),key='-bglj-'),sg.FileBrowse('\u9009\u62e9',key='-xz1-')],#sg.FileBrowse\u9009\u62e9\u6587\u4ef6\u8def\u5f84\uff0c\u548csg.T\u540c\u4e00\u884c\u4f1a\u81ea\u52a8\u4f20\u9012\u8def\u5f84\u4fe1\u606f\u5230sg.T\n&#x5B;sg.T('\u4fdd\u5b58\u8def\u5f84:',size=(8,1),key='-xb-'),sg.T(' ',size=(40,1),key='-bclj-'),sg.FolderBrowse('\u9009\u62e9',key='-xz2-')],#sg.FolderBrowse\u9009\u62e9\u6587\u4ef6\u5939\u8def\u5f84\uff0c\u548csg.T\u540c\u4e00\u884c\u4f1a\u81ea\u52a8\u4f20\u9012\u8def\u5f84\u4fe1\u606f\u5230sg.T\n&#x5B;sg.T(' ',size=(20,2)),sg.B('\u8f6c\u6362',size=(8,2),key='-zh-')]\n]\nwindow=sg.Window('Excel\u8f6c\u6362HTML\u8868\u683c',layout)\nwhile True:\n    event,values=window.read()\n    if event==None:\n        break\n    if event=='-zh-':\n        if values&#x5B;'-xz1-']==&quot;&quot; or values&#x5B;'-xz2-']==&quot;&quot;:\n            sg.Popup('\u8bf7\u9009\u62e9\u8868\u683c\u548c\u8f6c\u6362\u540e\u7684\u4fdd\u5b58\u8def\u5f84!')\n        elif &quot;.xlsx&quot; not in values&#x5B;'-xz1-']:\n            sg.Popup('\u53ea\u652f\u6301\u8f6c\u6362xlsx\u4e3a\u540e\u7f00\u7684\u8868\u683c\u6587\u4ef6!')\n        else:\n            print(&quot;\u8f6c\u6362\u5f00\u59cb&quot;)\n            data_processing()\n            sg.Popup('\u5904\u7406\u5b8c\u6210')\nwindow.close()\n\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u539f\u8868\u683c\u4e2d\u7b7e\u540d\u4e3a\u8def\u5f84\u4fe1\u606f\uff0c\u65e0\u6cd5\u67e5\u770b\uff01 \u8f6c\u6362\u540e\u5c06\u56fe\u7247\u8def\u5f84\u89e3\u6790\u6210\u56fe\u7247\u663e\u793a\u51fa\u6765 \u901a\u8fc7ie\u6253\u5f00\u540e\u7528\u865a\u62df\u6253\u5370\u673a\u53ef\u4ee5\u5c06\u9875\u9762\u6253&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/www.lucas88.cn\/?p=186\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-186","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=186"}],"version-history":[{"count":1,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/186\/revisions"}],"predecessor-version":[{"id":191,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/186\/revisions\/191"}],"wp:attachment":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}