{"id":232989,"date":"2020-12-29T06:21:06","date_gmt":"2020-12-28T22:21:06","guid":{"rendered":"http:\/\/4563.org\/?p=232989"},"modified":"2020-12-29T06:21:06","modified_gmt":"2020-12-28T22:21:06","slug":"%e6%80%8e%e4%b9%88%e6%9f%a5%e7%9c%8b-pywin32-%e7%9a%84-api-%e6%96%87%e6%a1%a3","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=232989","title":{"rendered":"\u600e\u4e48\u67e5\u770b pywin32 \u7684 API \u6587\u6863"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u600e\u4e48\u67e5\u770b pywin32 \u7684 API \u6587\u6863               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : QianGu <\/span>  <span><i><\/i> 17<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u56e0\u4e3a\u5176\u4ed6\u7684\u5e38\u7528 package \u65e0\u6cd5\u6ee1\u8db3\u9700\u6c42\uff0c\u53ea\u80fd\u4f7f\u7528 com\uff0c\u4f46\u662f\u8c8c\u4f3c com \u7684\u63a5\u53e3\u548c pywin32 \u4e0d\u662f\u5b8c\u5168\u4e00\u81f4\uff0c\u6c42\u95ee\u600e\u4e48\u67e5\u770b pywin32 \u63d0\u4f9b\u7684 API \u63a5\u53e3\u5462\uff0c\u5b98\u7f51\u6ca1\u6709\u63d0\u4f9b\u6587\u6863\uff0c<code>dir()<\/code> \u548c <code>help()<\/code> \u4e5f\u4e0d\u591f\u7528\u3002<\/p>\n<p>\u4e3e\u4e2a\u4f8b\u5b50<\/p>\n<pre><code>app = DispatchEx('Excel.Application') book = app.Workbooks.Open('my_file.xls) sheet = book.Worksheets('sheet1') # calculate coordinates sheet.Shapes.AddLine(x1, y1, x2, y2) <\/code><\/pre>\n<p>\u6211\u60f3\u8bbe\u7f6e line \u7684\u5c5e\u6027\uff0c\u4f46\u662f\u4e0d\u77e5\u9053\u76f8\u5173\u63a5\u53e3\u662f\u4ec0\u4e48\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4537032\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ysc3839 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u6ca1\u7528\u8fc7 pywin32\uff0c\u53ea\u7528\u8fc7 comtypes\uff0c\u5370\u8c61\u4e2d\u540e\u8005\u53ef\u4ee5\u770b IDispatch \u7684\u51fd\u6570\u5217\u8868\u7684\u3002<br \/>\u6216\u8005\u53ef\u4ee5\u76f4\u63a5\u770b Excel \u7684\u6587\u6863\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4537033\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : krixaar <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/docs.microsoft.com\/en-us\/office\/vba\/api\/excel.shapes.addline<br \/>Excel \u7684\u8bdd\uff0c\u76f4\u63a5\u770b VBA \u7684\u6587\u6863\u5f97\u4e86\uff0c\u4f30\u8ba1\u7528\u8d77\u6765\u5dee\u4e0d\u591a\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4537034\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : imn1 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             google: &#8220;pywin32.chm&#8221;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4537035\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : QianGu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ysc3839 \u6211\u9047\u5230\u7684\u95ee\u9898\u5c31\u662f pywin32 \u7684\u63a5\u53e3\u548c Excel \u7684\u6587\u6863\u63a5\u53e3\u4f3c\u4e4e\u4e0d\u4e00\u6837\uff0cExcel \u7684\u6587\u6863\u91cc\u9762\u662f VB \u63a5\u53e3\uff0c\u7167\u7740\u7c7b\u4f3c\u7684\u8bed\u6cd5\u5199 python \u62a5\u9519\u4e86\uff0c\u4f46\u662f\u53c8\u6ca1\u6709\u9014\u5f84\u77e5\u9053 pywin32 \u63d0\u4f9b\u51c6\u786e\u7684\u63a5\u53e3\uff0c\u57fa\u672c\u90fd\u662f\u9760\u731c\u6765\u5199\u7684\u3002<br \/>\u8fd8\u662f\u8bf4\uff0c\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\u7684 sheet \u7684\u5c5e\u6027\u3001\u65b9\u6cd5\u8fd9\u4e9b\u63a5\u53e3\u672c\u8eab\u5df2\u7ecf\u4e0d\u662f pywin32 \u7684\u4e86\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4537036\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : QianGu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @krixaar \u786e\u5b9e\uff0c\u6211\u5c31\u662f\u770b\u7740 VB \u731c\u7740\u5199 python\uff0c\u53ef\u4ee5 addline \u4f46\u662f\u4e0d\u4f1a\u6539\u5c5e\u6027 \ud83d\ude41                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4537037\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ysc3839 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @QianGu \u6211\u4e4b\u524d\u7528 comtypes\uff0c\u770b Excel \u7684 VBA \u6587\u6863\uff0c\u4f3c\u4e4e\u6ca1\u4ec0\u4e48\u95ee\u9898\u2026\u2026<br \/>\u4e2a\u4eba\u8fd8\u662f\u63a8\u8350\u7528 comtypes\uff0cpywin32 \u5e26\u4e86\u4e00\u5927\u5806\u4e1c\u897f\uff0c\u592a\u91cd\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4537038\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : QianGu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ysc3839 \u8c22\u8c22~\u6211\u8bd5\u8bd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4537039\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : QianGu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @imn1 \u8c22\u8c22\uff0cpywin32 \u7684\u6587\u6863\u672c\u8eab\u6709\u5728\u7ebf\u7684\uff0c\u4e5f\u6709\u79bb\u7ebf\u7684\uff0c\u5c31\u5728 package \u76ee\u5f55\u4e0b\u9762\u3002<br \/>StackOverflow \u4e0a\u4e5f\u6709\u76f8\u540c\u7684\u95ee\u9898\uff0c<br \/>https:\/\/stackoverflow.com\/questions\/5481686\/why-cant-i-find-any-pywin32-documentation-resources<\/p>\n<p>\u5e94\u8be5\u662f\u6211\u95ee\u9519\u95ee\u9898\u4e86\uff0c\u6211\u7684\u95ee\u9898\u5e94\u8be5\u662f\u4ece VB \u7684\u8bed\u6cd5\u6620\u5c04\u5230 python \u8bed\u6cd5                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u600e\u4e48\u67e5\u770b pywin32 \u7684 AP&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/232989"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=232989"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/232989\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=232989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=232989"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=232989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}