{"id":2692,"date":"2026-07-16T16:07:08","date_gmt":"2026-07-16T08:07:08","guid":{"rendered":"https:\/\/www.jh1999.cn\/?p=2692"},"modified":"2026-07-16T17:23:11","modified_gmt":"2026-07-16T09:23:11","slug":"ax%e7%94%a8%e4%ba%a7%e5%93%81%e5%9e%8b%e5%8f%b7%e5%88%86%e6%a0%8f%e5%81%9a%e7%bb%9f%e8%ae%a1","status":"publish","type":"post","link":"http:\/\/www.jh1999.cn\/?p=2692","title":{"rendered":"AX\u7528\u4ea7\u54c1\u578b\u53f7\u5206\u680f\u505a\u7edf\u8ba1"},"content":{"rendered":"<div class=\"gb-container gb-container-6ab208ea\">\n\n<p class=\"has-medium-font-size wp-block-paragraph\">AX\u7cfb\u7edf\u91cc\uff0cX++\u8bed\u8a00\u6309\u6708\u4efd+\u4ea7\u54c1\u578b\u53f7\u7edf\u8ba1\u4ea7\u91cf\u662f\u5e38\u89c4\u64cd\u4f5c\uff0c\u5982\u679c\u8981\u628a\u67d0\u4e2a\u65e5\u671f\u8303\u56f4\u91cc\u751f\u4ea7\u8fc7\u7684\u4ea7\u54c1\u578b\u53f7\u505a\u4e3a\u680f\uff08\u76f8\u5f53\u4e8e\u5b57\u6bb5\uff09\u6765\u7edf\u8ba1\u751f\u4ea7\u6570\u91cf\uff0c\u9700\u8981\u4e00\u4e9b\u6298\u4e2d\u7684\u4ee3\u7801\u6765\u5b9e\u73b0\u3002<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">\u4e0b\u9762\u4ee3\u7801\u662f\u5b9e\u4f8b\uff0c\u76ee\u7684\uff1a\u8f93\u5165\u4ece\u65e5\u671f \u548c \u5230\u671f\u671f \u4e24\u4e2a\u53c2\u6570\uff0c\u7edf\u8ba1\u751f\u4ea7\u6570\u91cf\uff0c\u8981\u6c42\u6bcf\u4e2a\u6708\u8f6e\u8be2\uff0c\u4ea7\u54c1\u578b\u53f7\u4f5c\u4e3a\u5217\u5934\uff0c\u7ed3\u679c\u8f93\u51fa\u5230Excel\u91cc\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void ProdSum2Excel(TransDate _fromDate, TransDate _toDate)\n{\n    \/\/ Excel \u5c0d\u8c61\n    SysExcelApplication   _excel;\n    SysExcelWorkbooks     _books;\n    SysExcelWorkbook      _book;\n    SysExcelWorksheets    _sheets;\n    SysExcelWorksheet     _sheet;\n    SysExcelCells         _cells;\n\n    \/\/ \u7d71\u8a08\u7528 Map: Key = \"26\u5e745\u6708|SP|\u98a8\u7b52\", Value = \u6578\u91cf\n    Map                   _dataMap;\n    str                   _mapKey;\n    int                   _mapValue;\n\n    \/\/ \u5217\u8868\uff08\u4fdd\u6301\u8f38\u51fa\u9806\u5e8f\uff09\n    List                  _monthList;\n    ListEnumerator        _monthEnum;\n    List                  _prodTypeList;\n    ListEnumerator        _typeEnum;\n    List                  _companyList;\n    ListEnumerator        _compEnum;\n\n    \/\/ \u7576\u524d\u8655\u7406\u8b8a\u91cf\n    str                   _currentMonth;\n    str                   _currentCompany;\n    str                   _currentType;\n    int                   _cellValue;\n    int                   _rowTotal;\n    int                   _colTotal;\n    int                   _row;\n    int                   _col;\n    int                   _startRow;\n    int                   _i;\n\n    \/\/ \u6578\u64da\u6e90\u8b8a\u91cf\n    SPL_DailyProd         _dailyProd;\n    SPL_OrderList         _orderList;\n    InventTable           _inventTable;\n    ProdLine              _prodLine;\n    TransDate             _prodDate;\n    str                   _company;\n    str                   _prodType;\n    int                   _qty;\n    str                   _monthKey;\n\n    \/\/ \u751f\u6210\u6708\u4efd\u5217\u8868\u7528\u8b8a\u91cf\n    TransDate             _tmpDate;\n    int                   _tmpYear;\n    int                   _tmpMonth;\n    str                   _tmpMonthKey;\n    int                   _loopCount;    \/\/ \u9632\u6b62\u6b7b\u5faa\u74b0\n    str                   _tmpStr;\n    ;\n\n    \/\/ 1. \u521d\u59cb\u5316\u5206\u516c\u53f8\u5217\u8868\uff08\u56fa\u5b9a\u9806\u5e8f\uff09\n    _companyList = new List(Types::String);\n    _companyList.addEnd(\"SP\");\n    _companyList.addEnd(\"JM\");\n    _companyList.addEnd(\"SR\");\n    \/\/_companyList.addEnd(\"JA\");    \/\/\u4e0d\u751f\u7522\u6210\u54c1\n\n    \/\/ 2. \u6839\u64da _fromDate \u548c _toDate \u751f\u6210\u6708\u4efd\u5217\u8868\n    _monthList = new List(Types::String);\n    if (_fromDate &gt; _toDate)\n    {\n        info(\"\u958b\u59cb\u65e5\u671f\u4e0d\u80fd\u5927\u65bc\u7d50\u675f\u65e5\u671f\");\n        return;\n    }\n\n    _tmpDate = _fromDate;\n    _loopCount = 0;\n\n    while (_tmpDate &lt;= _toDate)\n    {\n        _loopCount++;\n        if (_loopCount &gt; 120)\n        {\n            info(\"\u6708\u4efd\u5faa\u74b0\u8d85\u904e\u5b89\u5168\u9650\u5236\uff0c\u8acb\u6aa2\u67e5\u65e5\u671f\u7bc4\u570d\");\n            break;\n        }\n\n        _tmpYear = year(_tmpDate);\n        _tmpMonth = MthOfYr(_tmpDate);\n        _tmpMonthKey = strFmt(\"%1\u5e74%2\u6708\",\n                        num2str(_tmpYear - 2000, 0, 0, 0, 0),\n                        num2str(_tmpMonth, 0, 0, 0, 0));\n\n        if (!element.isInList(_monthList, _tmpMonthKey))\n        {\n            _monthList.addEnd(_tmpMonthKey);\n        }\n\n        \/\/ \u79fb\u5230\u4e0b\u500b\u67081\u865f\uff08\u4f7f\u7528 dateMthFwd \u66f4\u5b89\u5168\uff09\n        _tmpDate = dateMthFwd(_tmpDate, 1);\n        \/\/ \u78ba\u4fdd\u662f\u4e0b\u500b\u67081\u865f\n        _tmpDate = mkDate(1, MthOfYr(_tmpDate), year(_tmpDate));\n    }\n\n    \/\/ 3. \u521d\u59cb\u5316\u6578\u64da\u7d50\u69cb\n    _dataMap = new Map(Types::String, Types::Integer);\n    _prodTypeList = new List(Types::String);\n\n    \/\/ 4. \u5f9e\u6578\u64da\u6e90\u8b80\u53d6\u4e26\u7d71\u8a08\u6578\u64da\uff08\u540c\u6642\u63d0\u53d6\u7522\u54c1\u985e\u578b\uff09\n    while select SPL_ProdDate, SPL_DailyQty from _dailyProd\n                    where   _dailyProd.SPL_ProdDate &gt;= _fromDate\n                    &amp;&amp;      _dailyProd.SPL_ProdDate &lt;= _toDate\n            join ItemId from _orderList\n                    where   _orderList.SalesLineRecId   == _dailyProd.SalesLineRecId\n            join SPL_NameAlias from _inventTable\n                    where   _inventTable.ItemId == _orderList.ItemId\n            join SPL_Factory from _prodLine\n                    where   _prodLine.ProdLineId    == _dailyProd.ProdLineId\n    {\n        _prodDate = _dailyProd.SPL_ProdDate;\n        _company = _prodLine.SPL_Factory;           \/\/ \u5206\u516c\u53f8\n        _prodType = _inventTable.SPL_NameAlias;     \/\/ \u7c21\u7a31\/\u7522\u54c1\u985e\u578b\n        _qty = _dailyProd.SPL_DailyQty;             \/\/ \u5b8c\u6210\u6578\u91cf\n\n        \/\/ \u751f\u6210\u6708\u4efdKey: \"26\u5e745\u6708\"\n        _monthKey = strFmt(\"%1\u5e74%2\u6708\",\n                    num2str(year(_prodDate) - 2000, 0, 0, 0, 0),\n                    num2str(MthOfYr(_prodDate), 0, 0, 0, 0));\n\n        \/\/ \u52d5\u614b\u6536\u96c6\u7522\u54c1\u985e\u578b\uff08\u53ea\u6536\u96c6\u904e\u6ffe\u5f8c\u6578\u64da\u4e2d\u51fa\u73fe\u7684\uff09\n        if (_prodType != \"\" &amp;&amp; !element.isInList(_prodTypeList, _prodType))\n        {\n            _prodTypeList.addEnd(_prodType);\n        }\n\n        \/\/ Map Key: \"26\u5e745\u6708|SP|\u98a8\u7b52\"\n        _mapKey = strFmt(\"%1|%2|%3\", _monthKey, _company, _prodType);\n\n        if (_dataMap.exists(_mapKey))\n        {\n            _mapValue = _dataMap.lookup(_mapKey) + _qty;\n            _dataMap.remove(_mapKey);\n            _dataMap.insert(_mapKey, _mapValue);\n        }\n        else\n        {\n            _dataMap.insert(_mapKey, _qty);\n        }\n    }\n\n    \/\/ 5. \u5275\u5efa Excel\n    _excel = SysExcelApplication::construct();\n    _excel.visible(false);\n\n    _books = _excel.workbooks();\n    _book = _books.add();\n    _sheets = _book.worksheets();\n    _sheet = _sheets.itemFromNum(1);\n    _tmpStr= strFmt(\"%1\u81f3%2\u751f\u7522\u7d71\u8a08\",date2str(_fromDate,321,2,3,2,3,2),date2str(_toDate,321,2,3,2,3,2));\n    _sheet.name(_tmpStr);\n    _cells = _sheet.cells();\n\n    _row = 1;\n\n    \/\/ 6. \u6309\u6708\u4efd\u5faa\u74b0\u8f38\u51fa\n    _monthEnum = _monthList.getEnumerator();\n    while (_monthEnum.moveNext())\n    {\n        _currentMonth = _monthEnum.current();\n\n        \/\/ ---- \u8f38\u51fa\u6708\u4efd\u6a19\u984c ----\n        _cells.item(_row, 1).value(_currentMonth);\n        _row++;\n\n        \/\/ ---- \u8f38\u51fa\u8868\u982d ----\n        _col = 1;\n        _cells.item(_row, _col).value(\"\u5206\u516c\u53f8\");\n        _col++;\n\n        _typeEnum = _prodTypeList.getEnumerator();\n        while (_typeEnum.moveNext())\n        {\n            _cells.item(_row, _col).value(_typeEnum.current());\n            _col++;\n        }\n        _cells.item(_row, _col).value(\"\u5c0f\u8a08\");\n        _row++;\n\n        _startRow = _row;\n\n        \/\/ ---- \u8f38\u51fa\u5404\u5206\u516c\u53f8\u6578\u64da ----\n        _compEnum = _companyList.getEnumerator();\n        while (_compEnum.moveNext())\n        {\n            _currentCompany = _compEnum.current();\n            _col = 1;\n            _cells.item(_row, _col).value(_currentCompany);\n            _col++;\n\n            _rowTotal = 0;\n\n            _typeEnum = _prodTypeList.getEnumerator();\n            while (_typeEnum.moveNext())\n            {\n                _currentType = _typeEnum.current();\n                _mapKey = strFmt(\"%1|%2|%3\", _currentMonth, _currentCompany, _currentType);\n\n                if (_dataMap.exists(_mapKey))\n                {\n                    _cellValue = _dataMap.lookup(_mapKey);\n                    _cells.item(_row, _col).value(_cellValue);\n                    _rowTotal += _cellValue;\n                }\n                else\n                {\n                    _cells.item(_row, _col).value(0);\n                }\n                _col++;\n            }\n\n            \/\/ \u5c0f\u8a08\n            _cells.item(_row, _col).value(_rowTotal);\n            _row++;\n        }\n\n        \/\/ ---- \u8f38\u51fa\u7d2f\u8a08\u884c ----\n        _col = 1;\n        _cells.item(_row, _col).value(\"\u7d2f\u8a08\");\n        _col++;\n\n        _typeEnum = _prodTypeList.getEnumerator();\n        while (_typeEnum.moveNext())\n        {\n            _currentType = _typeEnum.current();\n            _colTotal = 0;\n\n            \/\/ \u904d\u6b77\u5404\u5206\u516c\u53f8\uff0c\u7d2f\u52a0\u8a72\u7522\u54c1\u985e\u578b\u7684\u503c\n            _compEnum = _companyList.getEnumerator();\n            while (_compEnum.moveNext())\n            {\n                _currentCompany = _compEnum.current();\n                _mapKey = strFmt(\"%1|%2|%3\", _currentMonth, _currentCompany, _currentType);\n\n                if (_dataMap.exists(_mapKey))\n                {\n                    _colTotal += _dataMap.lookup(_mapKey);\n                }\n            }\n\n            _cells.item(_row, _col).value(_colTotal);\n            _col++;\n        }\n\n        \/\/ \u7d2f\u8a08\u5c0f\u8a08 = \u5404\u5206\u516c\u53f8\u5c0f\u8a08\u4e4b\u548c\n        _colTotal = 0;\n        _compEnum = _companyList.getEnumerator();\n        while (_compEnum.moveNext())\n        {\n            _currentCompany = _compEnum.current();\n            _rowTotal = 0;\n            _typeEnum = _prodTypeList.getEnumerator();\n            while (_typeEnum.moveNext())\n            {\n                _currentType = _typeEnum.current();\n                _mapKey = strFmt(\"%1|%2|%3\", _currentMonth, _currentCompany, _currentType);\n\n                if (_dataMap.exists(_mapKey))\n                {\n                    _rowTotal += _dataMap.lookup(_mapKey);\n                }\n            }\n            _colTotal += _rowTotal;\n        }\n        _cells.item(_row, _col).value(_colTotal);\n\n        _row++;\n        _row++;  \/\/ \u7a7a\u4e00\u884c\u5206\u9694\n    }\n\n    \/\/ 7. \u81ea\u52d5\u8abf\u6574\u5217\u5bec\n    _col = 2 + _prodTypeList.elements();\n    for (_i = 1; _i &lt;= _col; _i++)\n    {\n        \/\/_sheet.columns().item(_i).autoFit();\n        _sheet.columns().item(_i).comObject().columnWidth(8.8);\n        _sheet.columns().item(_i).numberFormat(\"#,##0\");\n        _sheet.columns().item(_i).comObject().horizontalAlignment(-4108);\n    }\n\n    \/\/ 8. \u76f4\u63a5\u986f\u793a Excel\uff0c\u8b93\u7528\u6236\u624b\u5de5\u4fdd\u5b58\n    _excel.visible(true);\n    info(\"Excel \u5831\u8868\u5df2\u751f\u6210\uff0c\u8acb\u5207\u63db\u5230Excel\u7a0b\u5f0f\");\n}<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">\u4e0a\u8ff0\u4ee3\u7801\u8c03\u7528\u4e86\u672cFORM\u4e2d\u4e2d\u5916\u4e24\u4e2aMethod\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u5217\u865f\u8f49\u5b57\u6bcd\uff081-&gt;A, 2-&gt;B...\uff09\nstr colNumToLetter(int _col)\n{\n    str _result = \"\";\n    int _dividend = _col;\n    int _modulo;\n    ;\n    while (_dividend &gt; 0)\n    {\n        _modulo = (_dividend - 1) mod 26;\n        _result = num2char(65 + _modulo) + _result;\n        _dividend = (_dividend - 1) \/ 26;\n    }\n\n    return _result;\n}\n\n\n\/\/\u6aa2\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u5728List\u4e2d\nboolean isInList(List _list, str _value)\n{\n    ListEnumerator _enum;\n    ;\n    _enum = _list.getEnumerator();\n    while (_enum.moveNext())\n    {\n        if (_enum.current() == _value)\n            return true;\n    }\n    return false;\n}<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"576\" height=\"768\" src=\"https:\/\/www.jh1999.cn\/wp-content\/uploads\/2026\/07\/girl7.png\" alt=\"\" class=\"wp-image-2707\" srcset=\"http:\/\/www.jh1999.cn\/wp-content\/uploads\/2026\/07\/girl7.png 576w, http:\/\/www.jh1999.cn\/wp-content\/uploads\/2026\/07\/girl7-225x300.png 225w\" sizes=\"auto, (max-width: 576px) 100vw, 576px\" \/><\/figure>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>AX\u7cfb\u7edf\u91cc\uff0cX++\u8bed\u8a00\u6309\u6708\u4efd+\u4ea7\u54c1\u578b\u53f7\u7edf\u8ba1\u4ea7\u91cf\u662f\u5e38\u89c4\u64cd\u4f5c\uff0c\u5982\u679c\u8981\u628a\u67d0\u4e2a\u65e5\u671f\u8303\u56f4\u91cc\u751f\u4ea7\u8fc7\u7684\u4ea7\u54c1\u578b\u53f7\u505a\u4e3a\u680f\uff08\u76f8\u5f53\u4e8e &#8230; <a title=\"AX\u7528\u4ea7\u54c1\u578b\u53f7\u5206\u680f\u505a\u7edf\u8ba1\" class=\"read-more\" href=\"http:\/\/www.jh1999.cn\/?p=2692\" aria-label=\"Read more about AX\u7528\u4ea7\u54c1\u578b\u53f7\u5206\u680f\u505a\u7edf\u8ba1\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-2692","post","type-post","status-publish","format-standard","hentry","category-kfbj"],"_links":{"self":[{"href":"http:\/\/www.jh1999.cn\/index.php?rest_route=\/wp\/v2\/posts\/2692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.jh1999.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jh1999.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jh1999.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jh1999.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2692"}],"version-history":[{"count":8,"href":"http:\/\/www.jh1999.cn\/index.php?rest_route=\/wp\/v2\/posts\/2692\/revisions"}],"predecessor-version":[{"id":2708,"href":"http:\/\/www.jh1999.cn\/index.php?rest_route=\/wp\/v2\/posts\/2692\/revisions\/2708"}],"wp:attachment":[{"href":"http:\/\/www.jh1999.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jh1999.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2692"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jh1999.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}