{"id":188,"date":"2019-05-03T11:20:09","date_gmt":"2019-05-03T03:20:09","guid":{"rendered":"http:\/\/www.hefeiyu.com\/?p=188"},"modified":"2019-05-03T11:20:09","modified_gmt":"2019-05-03T03:20:09","slug":"tiptop-excel%e5%af%bc%e5%85%a5%e6%ad%a3%e5%b8%b8%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.hefeiyu.com\/?p=188","title":{"rendered":"TIPTOP EXCEL\u5bfc\u5165\u6b63\u5e38\u65b9\u6cd5"},"content":{"rendered":"<blockquote><p>\u524d\u671f\u6587\u7ae0\u4e2d\uff0c\u6709\u4e24\u4e09\u79cd\u5bfc\u5165\u65b9\u6cd5\u3002\u6709\u7684\u9700\u8981EXCEL\u5904\u4e8e\u6253\u5f00\u72b6\u6001\uff0c\u6709\u7684\u9700\u8981\u8f6c\u6210CSV\u3002\u672c\u4f8b\u662f\u6700\u5e38\u7528\u65b9\u6cd5\uff0c\u5982\u4f60\u60f3\u8c61\u4e2d\u7684\u6837\u5b50\u3002<\/p><\/blockquote>\n<p>\u3002\u3002\u3002<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">FUNCTION t110_impexcel()\r\n  DEFINE ls_str   STRING,\r\n         ls_file  STRING,\r\n         ls_loction STRING,\r\n         gs_location STRING\r\n         \r\n  LET ls_str =cl_getmsg(\"lib-201\",g_lang) \r\n  WHILE TRUE \r\n    PROMPT ls_str CLIPPED FOR gs_location\r\n    ATTRIBUTE(WITHOUT defaults)\r\n       \r\n        ON action accept\r\n           EXIT WHILE \r\n        ON action cancel\r\n           LET gs_location=NULL \r\n           EXIT WHILE   \r\n        ON action browse_document\r\n           LET ls_file = cl_browse_file()\r\n           IF ls_file IS NOT NULL THEN \r\n           \t  LET gs_location = ls_file\r\n           \tEND IF \r\n        ON idle g_idle_seconds\r\n           CALL cl_on_idle()\r\n           RETURN \r\n           \r\n     END PROMPT \r\n     END WHILE \r\n   \r\n   IF NOT cl_null(gs_location) THEN \r\n   \t  CALL t110_impexcel_p(gs_location)\r\n   \tEND IF \r\n           \t\r\nEND FUNCTION \r\n\r\n#17011201\r\nFUNCTION t110_impexcel_p(p_fileloc)\r\n  DEFINE  l_flag       LIKE type_file.chr1\r\n  DEFINE  p_fileloc   string\r\n  DEFINE  xlApp,iRes,iRow,i,j INTEGER \r\n  DEFINE li_k,l_cnt LIKE  type_file.num5\r\n  DEFINE li_i_r LIKE  type_file.num5\r\n  DEFINE lr_err  DYNAMIC ARRAY OF RECORD \r\n                 line  string,\r\n                 key1  string,\r\n                 err   string \r\n         END RECORD \r\n  DEFINE l_abb RECORD LIKE abb_file.*\r\n   \r\n  CALL s_showmsg_init() \r\n  LET l_flag='Y'\r\n  BEGIN WORK       \r\n  CALL ui.interface.frontCall('WinCOM','CreateInstance',['Excel.Application'],[xlApp])\r\n  IF xlApp &lt;&gt; -1 THEN \r\n  \t CALL ui.interface.frontCall('WinCOM','CallMethod',[xlApp,'WorkBooks.Open',p_fileloc],[iRes])\r\n  \r\n     IF iRes &lt;&gt; -1 THEN \r\n     \tCALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.UsedRange.Rows.Count'],[iRow])\t \r\n     \t  IF  iRow &gt; 1 THEN \r\n     \t  \t LET li_k = 1\r\n     \t  \t FOR i=2 TO iRow\r\n     \t  \t   INITIALIZE l_abb.* TO NULL \r\n     \t  \t    \r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',1).Value'],[l_abb.abb03])  \r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',2).Value'],[l_abb.abb04]) \r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',3).Value'],[l_abb.abb05])\r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',4).Value'],[l_abb.abb06]) \r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',5).Value'],[l_abb.abb24])\r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',6).Value'],[l_abb.abb25])\r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',7).Value'],[l_abb.abb07f])\r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',8).Value'],[l_abb.abb07]) \r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',9).Value'],[l_abb.abb08])\r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',10).Value'],[l_abb.abb11]) \r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',11).Value'],[l_abb.abb12])\r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',12).Value'],[l_abb.abb13])\r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',13).Value'],[l_abb.abb14])\r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',14).Value'],[l_abb.abb31])      \r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',15).Value'],[l_abb.abb35]) \r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',16).Value'],[l_abb.abb36])\r\n     \t      CALL ui.interface.frontCall('WinCOM','GetProperty',[xlApp,'ActiveSheet.Cells('||i||',17).Value'],[l_abb.abb37]) \r\n     \t     \r\n     \t      LET l_abb.abb00=g_aba.aba00\r\n     \t      LET l_abb.abb01=g_aba.aba01\r\n     \t      LET l_abb.abb02=i-1\r\n     \t      LET l_abb.abblegal=g_aba.abalegal \r\n     \t      LET l_cnt=0\r\n     \t      SELECT COUNT(0) INTO l_cnt FROM  aag_file WHERE aag01=l_abb.abb03 AND aagacti='Y' \r\n     \t      IF l_cnt=0 THEN\r\n     \t      \t LET l_flag='N'\r\n     \t      \t CALL s_errmsg('',i-1,l_abb.abb03,'cgl-005',1) \r\n     \t      END IF  \r\n   \t      \r\n     \t      LET l_cnt=0\r\n     \t      IF NOT cl_null(l_abb.abb05) AND l_abb.abb05&lt;&gt;' ' THEN  #\u90e8\u95e8\u4e0d\u4e3a\u7a7a\u65f6\uff0c\u624d\u8fdb\u884c\u6b64\u9879\r\n     \t        SELECT count(0) INTO l_cnt FROM gem_file WHERE gem01=l_abb.abb05 AND gemacti='Y'      \r\n     \t        IF l_cnt=0 THEN \r\n     \t      \t   LET l_flag='N'\r\n     \t      \t   CALL s_errmsg('',i-1,l_abb.abb05,'cgl-006',1) \r\n     \t        END IF \r\n     \t      END IF \r\n     \t      LET l_cnt=0\r\n     \t      SELECT count(0) INTO l_cnt FROM azi_file WHERE azi01=l_abb.abb24 AND aziacti='Y' \r\n     \t      IF l_cnt=0 THEN \r\n     \t      \t LET l_flag='N'\r\n     \t      \t CALL s_errmsg('',i-1,l_abb.abb24,'cgl-008',1) \r\n     \t      END IF \r\n            INSERT INTO abb_file VALUES(l_abb.*)\r\n     \t      IF SQLCA.sqlcode OR SQLCA.sqlerrd[3]=0 THEN \r\n     \t      \t  LET l_flag='N'\r\n     \t      \t  CALL s_errmsg('',i-1,SQLCA.sqlcode,'cgl-007',1) \r\n     \t      \t \tCONTINUE FOR \r\n     \t      END IF\r\n     \t     END FOR \r\n     \t END IF \r\n     \t \r\n     ELSE \r\n     \t     MESSAGE  'NO file' \r\n     END IF \r\n  ELSE \r\n     \t     MESSAGE  'NO EXCEl'\r\n  END IF  \r\n  IF l_flag='Y' THEN \r\n  \tSELECT sum(abb07) INTO g_aba.aba08 FROM abb_file WHERE abb01=g_aba.aba01 AND abb06='1'\r\n  \tSELECT sum(abb07) INTO g_aba.aba09 FROM abb_file WHERE abb01=g_aba.aba01 AND abb06='2'\r\n  \tIF cl_null(g_aba.aba08) THEN LET g_aba.aba08=0 END IF \r\n  \tIF cl_null(g_aba.aba09) THEN LET g_aba.aba09=0 END IF \r\n  \tUPDATE aba_file SET aba08=g_aba.aba08,\r\n  \t                    aba09=g_aba.aba09\r\n  \tWHERE aba01=g_aba.aba01\r\n  \tIF SQLCA.sqlcode THEN \r\n  \t\t LET l_flag='N'\r\n       CALL s_errmsg('',0,SQLCA.sqlcode,'cgl-009',1) \r\n  \tEND IF \r\n  END IF   \t  \r\n  CALL ui.interface.frontCall('WinCOM','CallMethod',[xlApp,'Quit'],[iRes])\r\n  CALL ui.interface.frontCall('WinCOM','ReleaseInstance',[xlApp],[iRes])\r\n  IF l_flag='N' THEN \r\n  \tROLLBACK WORK \r\n  \tCALL s_showmsg()\r\n  ELSE \r\n  \tCOMMIT WORK\r\n  \tDISPLAY BY NAME g_aba.aba08,g_aba.aba09\r\n    CALL t110_show()\r\n  END IF   \r\n    \r\nEND FUNCTION  <\/code><\/pre>\n<p>&nbsp;<\/p>\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=188\">TIPTOP EXCEL\u5bfc\u5165\u6b63\u5e38\u65b9\u6cd5<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u524d\u671f\u6587\u7ae0\u4e2d\uff0c\u6709\u4e24\u4e09\u79cd\u5bfc\u5165\u65b9\u6cd5\u3002\u6709\u7684\u9700\u8981EXCEL\u5904\u4e8e\u6253\u5f00\u72b6\u6001\uff0c\u6709\u7684\u9700\u8981\u8f6c\u6210CSV\u3002\u672c\u4f8b\u662f\u6700\u5e38\u7528\u65b9\u6cd5\uff0c\u5982\u4f60\u60f3\u8c61\u4e2d\u7684\u6837\u5b50\u3002 \u3002\u3002\u3002 FUNCTION t110_impexcel() DEFINE ls_str STRING, ls_file STRING [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[88,75],"class_list":["post-188","post","type-post","status-publish","format-standard","hentry","category-4gl","tag-str","tag-string"],"_links":{"self":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/188","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=188"}],"version-history":[{"count":1,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":189,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions\/189"}],"wp:attachment":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}