{"id":5238,"date":"2019-08-27T11:13:09","date_gmt":"2019-08-27T03:13:09","guid":{"rendered":"http:\/\/www.hefeiyu.com\/?p=5238"},"modified":"2019-08-22T11:13:56","modified_gmt":"2019-08-22T03:13:56","slug":"t100-%e6%8c%89xls%e6%a0%bc%e5%bc%8f%e6%89%b9%e9%87%8f%e5%af%bc%e5%85%a5%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/www.hefeiyu.com\/?p=5238","title":{"rendered":"T100\u2014\u2014\u6309xls\u683c\u5f0f\u6279\u91cf\u5bfc\u5165\u6570\u636e"},"content":{"rendered":"<p>\u5f39\u51faFile\u00a0Browser\u7a97\u53e3<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.hefeiyu.com\/wp-content\/uploads\/2019\/08\/312546-20190314154521282-460444597.png\" alt=\"\" \/><\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">PRIVATE FUNCTION cxrt020_open_file()\r\nDEFINE l_dir        LIKE type_t.chr500\r\nDEFINE r_success   LIKE type_t.num5\r\n    #\r\n    LET r_success = FALSE\r\n    CALL cl_client_browse_file() RETURNING l_dir\r\n    IF NOT cl_null(l_dir) THEN\r\n        CALL cxrt020_ins_excel(l_dir) RETURNING r_success\r\n    END IF\r\n    RETURN r_success\r\n    \r\nEND FUNCTION<\/code><\/pre>\n<p>######\u6309\u8def\u5f84\uff0c\u628axls\u7684\u6570\u636e\u6309\u683c\u5f0f\u987a\u5e8fins\u5230\u6570\u636e\u8868\uff0c\u6ce8\u610fxls\u7684\u6587\u4ef6\u540d\u4e0d\u80fd\u6709\u4e2d\u6587\u6216\u7279\u6b8a\u7b26\u53f7\uff0c\u6700\u597d\u5168\u82f1\u6587\u6587\u4ef6\u540d\uff1b<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">PRIVATE FUNCTION cxrt020_ins_excel(p_excelname)\r\nDEFINE p_excelname LIKE type_t.chr1000  #excel\u6863\u540d\r\nDEFINE r_success   LIKE type_t.num5\r\nDEFINE l_excelname STRING               #excel\u6863\u540d\r\nDEFINE l_count     LIKE type_t.num10\r\nDEFINE li_i        LIKE type_t.num10\r\nDEFINE li_j        LIKE type_t.num10\r\nDEFINE xlapp,iRes,iRow    LIKE type_t.num5\r\nDEFINE l_xrsguc    RECORD LIKE xrsguc_t.*\r\nDEFINE l_today     LIKE type_t.dat       \r\nDEFINE l_n         LIKE type_t.num5\r\n\r\n   WHENEVER ERROR CONTINUE\r\n   LET r_success = TRUE\r\n\r\n   LET l_today= cl_get_current()\r\n   LET l_count = LENGTH(p_excelname CLIPPED)\r\n   #\u8f6c\u6362\u8def\u5f84\u5206\u9694\u7b26\r\n   FOR li_i = 1 TO l_count\r\n       IF p_excelname[li_i,li_i] =\"\/\" THEN\r\n          LET l_excelname = l_excelname CLIPPED,'\\\\'\r\n       ELSE\r\n          LET l_excelname = l_excelname CLIPPED,p_excelname[li_i,li_i]\r\n       END IF\r\n   END FOR\r\n\r\n   CALL ui.interface.frontCall('WinCOM','CreateInstance',\r\n                               ['Excel.Application'],[xlApp])\r\n   IF xlApp &lt;&gt; -1 THEN\r\n      CALL ui.interface.frontCall('WinCOM','CallMethod',\r\n                                  [xlApp,'WorkBooks.Open',l_excelname],[iRes])\r\n      IF iRes &lt;&gt; -1 THEN\r\n         CALL ui.interface.frontCall('WinCOM','GetProperty',\r\n              [xlApp,'ActiveSheet.UsedRange.Rows.Count'],[iRow])\r\n         IF iRow &gt; 1 THEN\r\n            FOR li_i = 2 TO iRow\r\n                INITIALIZE l_xrsguc.* TO NULL\r\n                LET l_xrsguc.xrsgucent = g_enterprise \r\n                LET l_xrsguc.xrsgucsite = g_site \r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',1).Value'],[l_xrsguc.xrsgucdocno])              \r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',2).Value'],[l_xrsguc.xrsguc001])\r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',3).Value'],[l_xrsguc.xrsguc002])\r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',4).Value'],[l_xrsguc.xrsguc003])\r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',5).Value'],[l_xrsguc.xrsguc004])\r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',6).Value'],[l_xrsguc.xrsguc005])\r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',7).Value'],[l_xrsguc.xrsguc006])\r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',8).Value'],[l_xrsguc.xrsguc007])\r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',9).Value'],[l_xrsguc.xrsguc008])\r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',10).Value'],[l_xrsguc.xrsguc009])\r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',11).Value'],[l_xrsguc.xrsguc010])\r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',12).Value'],[l_xrsguc.xrsguc011])\r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',13).Value'],[l_xrsguc.xrsguc012])\r\n                CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||li_i||',14).Value'],[l_xrsguc.xrsguc013])\r\n                #\r\n                INSERT INTO xrsguc_t VALUES l_xrsguc.*\r\n                IF SQLCA.sqlcode THEN\r\n                   INITIALIZE g_errparam TO NULL\r\n                   LET g_errparam.code = SQLCA.sqlcode\r\n                   LET g_errparam.extend = 'INSERT INTO xrsguc_t'\r\n                   LET g_errparam.popup = FALSE\r\n                   CALL cl_err()\r\n                   LET r_success = FALSE\r\n                   EXIT FOR\r\n                END IF\r\n            END FOR\r\n         END IF\r\n      ELSE\r\n         INITIALIZE g_errparam TO NULL\r\n         LET g_errparam.code = 'axc-00387'\r\n         LET g_errparam.extend = ''   #NO FILE\r\n         LET g_errparam.popup = TRUE\r\n         CALL cl_err()\r\n         LET r_success = FALSE\r\n      END IF\r\n   ELSE\r\n      INITIALIZE g_errparam TO NULL\r\n      LET g_errparam.code = 'axc-00387'\r\n      LET g_errparam.extend = ''  #NO EXCEL\r\n      LET g_errparam.popup = TRUE\r\n      CALL cl_err()\r\n      LET r_success = FALSE\r\n   END IF\r\n\r\n   CALL ui.interface.frontCall('WinCOM','CallMethod',[xlApp,'Quit'],[iRes])\r\n   CALL ui.interface.frontCall('WinCOM','ReleaseInstance',[xlApp],[iRes])\r\n\r\n   RETURN r_success\r\n\r\nEND FUNCTION<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/www.hefeiyu.com\">\u8d6b\u975e\u57df<\/a> &raquo; <a href=\"https:\/\/www.hefeiyu.com\/?p=5238\">T100\u2014\u2014\u6309xls\u683c\u5f0f\u6279\u91cf\u5bfc\u5165\u6570\u636e<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u5f39\u51faFile\u00a0Browser\u7a97\u53e3 PRIVATE FUNCTION cxrt020_open_file() DEFINE l_dir LIKE type_t.chr500 DEFINE r_success LIKE type_t.num5 # LET [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[490],"tags":[782,159,783],"class_list":["post-5238","post","type-post","status-publish","format-standard","hentry","category-490","tag-dir","tag-file","tag-success"],"_links":{"self":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/5238","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5238"}],"version-history":[{"count":1,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/5238\/revisions"}],"predecessor-version":[{"id":5240,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/5238\/revisions\/5240"}],"wp:attachment":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}