{"id":49393,"date":"2024-12-02T16:11:48","date_gmt":"2024-12-02T08:11:48","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49393\/"},"modified":"2024-12-02T16:11:48","modified_gmt":"2024-12-02T08:11:48","slug":"excel%e4%b8%8b%e6%8b%89%e5%88%97%e8%a1%a8%e9%a1%b9%e8%bf%87%e5%a4%9a%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49393\/","title":{"rendered":"Excel\u4e0b\u62c9\u5217\u8868\u9879\u8fc7\u591a\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Excel\u4e0b\u62c9\u5217\u8868\u9879\u8fc7\u591a\u5982\u4f55\u89e3\u51b3\uff1f<\/h1>\n<p>IT\u884c\u4e1a\u76f8\u5bf9\u4e8e\u4e00\u822c\u4f20\u7edf\u884c\u4e1a\uff0c\u53d1\u5c55\u66f4\u65b0\u901f\u5ea6\u66f4\u5feb\uff0c\u4e00\u65e6\u505c\u6b62\u4e86\u5b66\u4e60\uff0c\u5f88\u5feb\u5c31\u4f1a\u88ab\u884c\u4e1a\u6240\u6dd8\u6c70\u3002\u6240\u4ee5\u6211\u4eec\u9700\u8981\u8e0f\u8e0f\u5b9e\u5b9e\u7684\u4e0d\u65ad\u5b66\u4e60\uff0c\u7cbe\u8fdb\u81ea\u5df1\u7684\u6280\u672f\uff0c\u5c24\u5176\u662f\u521d\u5b66\u8005\u3002\u4eca\u5929\u7c73\u4e91\u7ed9\u5927\u5bb6\u6574\u7406\u4e86\u300aExcel\u4e0b\u62c9\u5217\u8868\u9879\u8fc7\u591a\u5982\u4f55\u89e3\u51b3\uff1f\u300b\uff0c\u804a\u804a\uff0c\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241201\/1733039855674c16efd0488.jpg\" class=\"aligncenter\" title=\"Excel\u4e0b\u62c9\u5217\u8868\u9879\u8fc7\u591a\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"Excel\u4e0b\u62c9\u5217\u8868\u9879\u8fc7\u591a\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>poi\u4e0b\u62c9\u5217\u8868\u9879\u8fc7\u591a<\/strong><\/p>\n<p>\u5728\u4f7f\u7528poi\u8bbe\u7f6eexcel\u4e0b\u62c9\u5217\u8868\u65f6\uff0c\u5982\u679c\u4e0b\u62c9\u9879\u8fc7\u591a\uff0c\u4e0b\u8f7d\u6a21\u677f\u540e\u53ef\u80fd\u65e0\u6cd5\u6b63\u786e\u663e\u793a\u3002\u8fd9\u662f\u56e0\u4e3apoi\u9ed8\u8ba4\u4f7f\u7528\u5185\u5b58\u7684\u6570\u636e\u7ed3\u6784\u6765\u5b58\u50a8\u4e0b\u62c9\u9879\uff0c\u5f53\u9009\u9879\u8fc7\u591a\u65f6\uff0c\u5185\u5b58\u6d88\u8017\u8fc7\u5927\uff0c\u4f1a\u51fa\u73b0\u6027\u80fd\u95ee\u9898\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u521b\u5efa\u53e6\u4e00\u4e2a\u4f5c\u4e3a\u5f15\u7528\u9875\u7684sheet\uff0c\u5e76\u4f7f\u7528\u516c\u5f0f\u6765\u5f15\u7528\u8be5sheet\u4e2d\u7684\u4e0b\u62c9\u9879\u5217\u8868\u3002\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u51cf\u5c11\u5185\u5b58\u6d88\u8017\uff0c\u4f7f\u5927\u91cf\u4e0b\u62c9\u9879\u4e5f\u80fd\u6b63\u5e38\u5c55\u793a\u3002<\/p>\n<pre>\/\/ \u521b\u5efa\u5f15\u7528\u9875\nXSSFSheet refSheet = workbook.createSheet(\"refSheet\");\n\n\/\/ \u5c06\u4e0b\u62c9\u9879\u5217\u8868\u6dfb\u52a0\u5230\u5f15\u7528\u9875\nfor (int i = 0; i &amp;lt; departList.length; i++) {\n    XSSFRow row = refSheet.createRow(i);\n    XSSFCell cell = row.createCell(0);\n    cell.setCellValue(departList[i]);\n}\n\n\/\/ \u4f7f\u7528\u516c\u5f0f\u5f15\u7528\u5f15\u7528\u9875\u7684\u5217\u8868\nString formula = \"refSheet!$A$1:$A$\" + departList.length;\nDataValidationConstraint constraint = helper.createFormulaListConstraint(formula);\n\n\/\/ ...\u5176\u4f59\u8bbe\u7f6e\u76f8\u540c<\/pre>\n<p>\u672c\u7bc7\u5173\u4e8e\u300aExcel\u4e0b\u62c9\u5217\u8868\u9879\u8fc7\u591a\u5982\u4f55\u89e3\u51b3\uff1f\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Excel\u4e0b\u62c9\u5217\u8868\u9879\u8fc7\u591a\u5982\u4f55\u89e3\u51b3\uff1f IT\u884c\u4e1a\u76f8\u5bf9\u4e8e\u4e00\u822c\u4f20\u7edf\u884c\u4e1a\uff0c\u53d1\u5c55\u66f4\u65b0\u901f\u5ea6\u66f4\u5feb\uff0c\u4e00\u65e6\u505c\u6b62\u4e86\u5b66\u4e60\uff0c\u5f88\u5feb\u5c31\u4f1a\u88ab\u884c\u4e1a\u6240\u6dd8\u6c70\u3002\u6240\u4ee5\u6211\u4eec\u9700\u8981\u8e0f\u8e0f\u5b9e\u5b9e\u7684\u4e0d\u65ad\u5b66\u4e60\uff0c\u7cbe\u8fdb\u81ea\u5df1\u7684\u6280\u672f\uff0c\u5c24\u5176\u662f\u521d\u5b66\u8005\u3002\u4eca\u5929\u7c73\u4e91\u7ed9\u5927\u5bb6\u6574\u7406\u4e86\u300aExcel\u4e0b\u62c9\u5217\u8868\u9879\u8fc7\u591a\u5982\u4f55\u89e3\u51b3\uff1f\u300b\uff0c\u804a\u804a\uff0c\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff01 poi\u4e0b\u62c9\u5217\u8868\u9879\u8fc7\u591a \u5728\u4f7f\u7528poi\u8bbe\u7f6eexcel\u4e0b\u62c9\u5217\u8868\u65f6\uff0c\u5982\u679c\u4e0b\u62c9\u9879\u8fc7\u591a\uff0c\u4e0b\u8f7d\u6a21\u677f\u540e\u53ef\u80fd\u65e0\u6cd5\u6b63\u786e\u663e\u793a\u3002\u8fd9\u662f\u56e0\u4e3apoi\u9ed8\u8ba4\u4f7f\u7528\u5185\u5b58\u7684\u6570\u636e\u7ed3\u6784\u6765\u5b58\u50a8\u4e0b\u62c9\u9879\uff0c\u5f53\u9009\u9879\u8fc7\u591a\u65f6\uff0c\u5185\u5b58\u6d88\u8017\u8fc7\u5927\uff0c\u4f1a\u51fa\u73b0\u6027\u80fd\u95ee\u9898\u3002 \u89e3\u51b3\u65b9\u6848 \u4e3a\u4e86\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u521b\u5efa\u53e6\u4e00\u4e2a\u4f5c\u4e3a\u5f15\u7528\u9875\u7684sheet\uff0c\u5e76\u4f7f\u7528\u516c\u5f0f\u6765\u5f15\u7528\u8be5sheet\u4e2d\u7684\u4e0b\u62c9\u9879\u5217\u8868\u3002\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u51cf\u5c11\u5185\u5b58\u6d88\u8017\uff0c\u4f7f\u5927\u91cf\u4e0b\u62c9\u9879\u4e5f\u80fd\u6b63\u5e38\u5c55\u793a\u3002 \/\/ \u521b\u5efa\u5f15\u7528\u9875 XSSFSheet refSheet = workbook.createSheet(&#8220;refSheet&#8221;); \/\/ \u5c06\u4e0b\u62c9\u9879\u5217\u8868\u6dfb\u52a0\u5230\u5f15\u7528\u9875 for (int i = 0; i &amp;lt; departList.length; i++) { XSSFRow row = refSheet.createRow(i); XSSFCell cell = row.createCell(0); cell.setCellValue(departList[i]); } \/\/ \u4f7f\u7528\u516c\u5f0f\u5f15\u7528\u5f15\u7528\u9875\u7684\u5217\u8868 String formula = &#8220;refSheet!$A$1:$A$&#8221; + departList.length; DataValidationConstraint constraint = helper.createFormulaListConstraint(formula); \/\/ &#8230;\u5176\u4f59\u8bbe\u7f6e\u76f8\u540c \u672c\u7bc7\u5173\u4e8e\u300aExcel\u4e0b\u62c9\u5217\u8868\u9879\u8fc7\u591a\u5982\u4f55\u89e3\u51b3\uff1f\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-49393","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=49393"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49393\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}