{"id":202777,"date":"2025-05-22T10:34:00","date_gmt":"2025-05-22T02:34:00","guid":{"rendered":"https:\/\/server.hk\/cnblog\/202777\/"},"modified":"2025-05-22T10:34:00","modified_gmt":"2025-05-22T02:34:00","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-excel-%e4%b8%ad%e4%bd%bf%e7%94%a8-poi-%e5%88%9b%e5%bb%ba%e5%b8%a6%e6%9c%89%e8%b6%85%e9%93%be%e6%8e%a5%e7%9a%84%e5%8d%95%e5%85%83%e6%a0%bc%ef%bc%8c%e5%b9%b6%e5%ae%9e","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/202777\/","title":{"rendered":"\u5982\u4f55\u5728 Excel \u4e2d\u4f7f\u7528 POI \u521b\u5efa\u5e26\u6709\u8d85\u94fe\u63a5\u7684\u5355\u5143\u683c\uff0c\u5e76\u5b9e\u73b0\u591a\u4e2a\u7f51\u5740\u5bf9\u5e94\u591a\u4e2a\u8d85\u94fe\u63a5\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u5728 Excel \u4e2d\u4f7f\u7528 POI \u521b\u5efa\u5e26\u6709\u8d85\u94fe\u63a5\u7684\u5355\u5143\u683c\uff0c\u5e76\u5b9e\u73b0\u591a\u4e2a\u7f51\u5740\u5bf9\u5e94\u591a\u4e2a\u8d85\u94fe\u63a5\uff1f<\/h1>\n<p>\u6587\u7ae0\u5c0f\u767d\u4e00\u679a\uff0c\u6b63\u5728\u4e0d\u65ad\u5b66\u4e60\u79ef\u7d2f\u77e5\u8bc6\uff0c\u73b0\u5c06\u5b66\u4e60\u5230\u7684\u77e5\u8bc6\u8bb0\u5f55\u4e00\u4e0b\uff0c\u4e5f\u662f\u5c06\u6211\u7684\u6240\u5f97\u5206\u4eab\u7ed9\u5927\u5bb6\uff01\u800c\u4eca\u5929\u8fd9\u7bc7\u6587\u7ae0\u300a\u5982\u4f55\u5728 Excel \u4e2d\u4f7f\u7528 POI \u521b\u5efa\u5e26\u6709\u8d85\u94fe\u63a5\u7684\u5355\u5143\u683c\uff0c\u5e76\u5b9e\u73b0\u591a\u4e2a\u7f51\u5740\u5bf9\u5e94\u591a\u4e2a\u8d85\u94fe\u63a5\uff1f\u300b\u5e26\u5927\u5bb6\u6765\u4e86\u89e3\u4e00\u4e0b##content_title##\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01<\/p>\n<p><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729940972671ccdecd14fd.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u5728 excel \u4e2d\u4f7f\u7528 poi \u521b\u5efa\u5e26\u6709\u8d85\u94fe\u63a5\u5355\u5143\u683c<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 poi \u5c06 excel \u8868\u683c\u5bfc\u51fa\u65f6\uff0c\u82e5\u9700\u5728\u4e00\u4e2a\u5355\u5143\u683c\u5185\u5c06\u591a\u4e2a\u7f51\u5740\u8f6c\u5316\u4e3a\u5bf9\u5e94\u7684\u8d85\u94fe\u63a5\uff0c\u9700\u8981\u501f\u52a9\u8fc2\u56de\u65b9\u6cd5\uff0c\u5176\u5927\u81f4\u65b9\u6848\u5982\u4e0b\uff1a<\/p>\n<p>\u589e\u52a0\u4e00\u4e2a\u900f\u660e\u7684\u77e9\u5f62\u653e\u7f6e\u4e8e\u5355\u5143\u683c\u4e4b\u4e0a\uff0c\u5e76\u8bbe\u7f6e\u8d85\u94fe\u63a5\u3002<\/p>\n<p>\u5177\u4f53\u5982\u4f55\u7528 poi \u5b9e\u73b0\uff1f<\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a\u8c03\u6574\u5355\u5143\u683c\u7684\u5927\u5c0f\u3002<\/p>\n<p>\u7b2c\u4e8c\u6b65\uff1a\u5c06\u77e9\u5f62\u653e\u7f6e\u5230\u5408\u9002\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\u7b2c\u4e09\u6b65\uff1a\u4f4d\u7f6e\u8ba1\u7b97\uff0c\u8003\u8651\u5230\u5b57\u4f53\u5927\u5c0f\u548c\u6587\u5b57\u7684\u52a8\u6001\u6539\u53d8\uff0c\u96be\u5ea6\u8f83\u9ad8\u3002<\/p>\n<p>\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u7684\u95ee\u9898\u9700\u8981\u8003\u8651\uff1a<\/p>\n<ul>\n<li>\u77e9\u5f62\u7684\u900f\u660e\u5ea6\u8bbe\u7f6e\u3002<\/li>\n<li>\u77e9\u5f62\u7684\u4f4d\u7f6e\u8ba1\u7b97\u3002<\/li>\n<\/ul>\n<p>\u6b64\u5916\uff0c\u8fd8\u6709\u4e00\u79cd\u66f4\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u76f4\u63a5\u5c06\u7f51\u5740\u653e\u5165\u5355\u5143\u683c\uff0cexcel \u80fd\u591f\u81ea\u52a8\u8bc6\u522b\u7f51\u5740\u5e76\u5141\u8bb8\u76f4\u63a5\u70b9\u51fb\uff0c\u4f46\u6b64\u65b9\u6cd5\u65e0\u6cd5\u4f7f\u7528\u522b\u540d\u3002<\/p>\n<p><strong>\u539f\u7b54\u6848<\/strong><\/p>\n<p>\u82e5\u8981\u4e3a\u5355\u5143\u683c\u8bbe\u7f6e\u8d85\u94fe\u63a5\uff0c\u53ef\u4ee5\u4f7f\u7528 org.apache.poi.ss.usermodel.cell \u65b9\u6cd5 sethyperlink\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>fun main() {\n    val url = \"https:\/\/segmentfault.com\/q\/1010000043471701\"\n\n    XSSFWorkbook().use { workbook -&gt;\n        FileOutputStream(\"test.xlsx\").use { fileout -&gt;\n            val sheet: Sheet = workbook.createSheet()\n            val link: Hyperlink = workbook.creationHelper.createHyperlink(HyperlinkType.URL)\n            link.address = url\n            val row: Row = sheet.createRow(0)\n            val cell: Cell = row.createCell(0)\n            val cellText = \"springboot\u5bfc\u51faexcel\uff1f\"\n            cell.setCellValue(cellText)\n            cell.hyperlink = link\n            sheet.setColumnWidth(0, cellText.length * 256)\n            workbook.write(fileout)\n        }\n    }\n}<\/pre>\n<p>\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\u4e86\uff0c\u662f\u5426\u6709\u987a\u5229\u5e2e\u52a9\u4f60\u89e3\u51b3\u95ee\u9898\uff1f\u82e5\u662f\u80fd\u7ed9\u4f60\u5e26\u6765\u5b66\u4e60\u4e0a\u7684\u5e2e\u52a9\uff0c\u8bf7\u5927\u5bb6\u591a\u591a\u652f\u6301\uff01\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u4e5f\u53ef\u5173\u6ce8\u516c\u4f17\u53f7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5728 Excel \u4e2d\u4f7f\u7528 PO&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-202777","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/202777","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=202777"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/202777\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=202777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=202777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=202777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}