{"id":53530,"date":"2024-12-03T14:02:23","date_gmt":"2024-12-03T06:02:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53530\/"},"modified":"2024-12-03T14:02:23","modified_gmt":"2024-12-03T06:02:23","slug":"exceljs%e5%af%bc%e5%87%baexcel%e5%8d%a1%e9%a1%bf%e6%80%8e%e4%b9%88%e5%8a%9e%ef%bc%9f%e5%a6%82%e4%bd%95%e4%bc%98%e5%8c%96%e5%af%bc%e5%87%ba%e6%80%a7%e8%83%bd%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53530\/","title":{"rendered":"ExcelJs\u5bfc\u51faExcel\u5361\u987f\u600e\u4e48\u529e\uff1f\u5982\u4f55\u4f18\u5316\u5bfc\u51fa\u6027\u80fd\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>ExcelJs\u5bfc\u51faExcel\u5361\u987f\u600e\u4e48\u529e\uff1f\u5982\u4f55\u4f18\u5316\u5bfc\u51fa\u6027\u80fd\uff1f<\/h1>\n<p><span style=\"color: #222222;, sans-serif;background-color: #FFFFFF\">\u5404\u4f4d\u5c0f\u4f19\u4f34\u4eec\uff0c\u5927\u5bb6\u597d\u5440\uff01\u770b\u770b\u4eca\u5929\u6211\u53c8\u7ed9\u5404\u4f4d\u5e26\u6765\u4e86\u4ec0\u4e48\u6587\u7ae0\uff1f\u672c\u6587\u6807\u9898<span style=\"color: #222222;, sans-serif;background-color: #FFFFFF\">\u662f<\/span><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aExcelJs\u5bfc\u51faExcel\u5361\u987f\u600e\u4e48\u529e\uff1f\u5982\u4f55\u4f18\u5316\u5bfc\u51fa\u6027\u80fd\uff1f\u300b<\/span>\uff0c\u5f88\u660e\u663e\u662f\u5173\u4e8e<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u7684\u6587\u7ae0\u54c8\u54c8\u54c8\uff0c\u5176\u4e2d\u5185\u5bb9\u4e3b\u8981\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u5982\u679c\u80fd\u5e2e\u5230\u4f60\uff0c\u89c9\u5f97\u5f88\u4e0d\u9519\u7684\u8bdd\uff0c\u6b22\u8fce\u5404\u4f4d\u591a\u591a\u70b9\u8bc4\u548c\u5206\u4eab\uff01<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241201\/1733045787674c2e1bc23a1.jpg\" class=\"aligncenter\" title=\"ExcelJs\u5bfc\u51faExcel\u5361\u987f\u600e\u4e48\u529e\uff1f\u5982\u4f55\u4f18\u5316\u5bfc\u51fa\u6027\u80fd\uff1f\u63d2\u56fe\" alt=\"ExcelJs\u5bfc\u51faExcel\u5361\u987f\u600e\u4e48\u529e\uff1f\u5982\u4f55\u4f18\u5316\u5bfc\u51fa\u6027\u80fd\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>exceljs\u5e93\u5bfc\u51faexcel\u5361\u987f\uff1f<\/strong><\/p>\n<p>\u5728\u4f7f\u7528exceljs\u5bfc\u51faexcel\u6587\u4ef6\u65f6\uff0c\u8bbe\u7f6e\u7279\u5b9a\u5217\u53ef\u7f16\u8f91\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u5bfc\u51fa\u901f\u5ea6\u53d8\u6162\u7684\u95ee\u9898\u3002\u672c\u6587\u5c06\u63a2\u8ba8\u4e00\u4e9b\u4f18\u5316\u5bfc\u51fa\u6027\u80fd\u7684\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li><strong>\u6279\u91cf\u64cd\u4f5c\uff1a<\/strong><br \/>\u907f\u514d\u9010\u4e2a\u5355\u5143\u683c\u8bbe\u7f6e\u4fdd\u62a4\u548c\u89e3\u9501\uff0c\u800c\u662f\u6279\u91cf\u64cd\u4f5c\u3002\u793a\u4f8b\uff1a<\/li>\n<\/ol>\n<pre>const unlockColumns = [6, 7, 8, 9, 12];\nsheet.columns.forEach((col, colNumber) =&amp;gt; {\n    if (unlockColumns.includes(colNumber + 1)) { \/\/ \u6307\u5b9a\u7279\u5b9a\u5217\n        col.eachCell((cell, rowNumber) =&amp;gt; {\n            if (rowNumber !== 1) { \/\/ \u8df3\u8fc7\u6807\u9898\u884c\n                cell.protection = { locked: false };\n            }\n        });\n    }\n});<\/pre>\n<ol>\n<li><strong>\u4f7f\u7528\u6a21\u677f\uff1a<\/strong><br \/>\u9884\u5148\u521b\u5efa\u6a21\u677f\u6587\u4ef6\uff0c\u8bbe\u7f6e\u597d\u6240\u9700\u4fdd\u62a4\u548c\u89e3\u9501\u8bbe\u7f6e\uff0c\u7136\u540e\u5c06\u6570\u636e\u5199\u5165\u6a21\u677f\u3002\u8fd9\u6837\u505a\u53ef\u4ee5\u51cf\u5c11\u52a8\u6001\u8bbe\u7f6e\u4fdd\u62a4\u7684\u5f00\u9500\u3002<\/li>\n<li><strong>\u4f18\u5316\u4ee3\u7801\u7ed3\u6784\uff1a<\/strong><br \/>\u907f\u514d\u8fc7\u5ea6\u5d4c\u5957\u548c\u5197\u4f59\u4ee3\u7801\uff0c\u4f7f\u5176\u66f4\u52a0\u7b80\u6d01\u9ad8\u6548\u3002<\/li>\n<\/ol>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300aExcelJs\u5bfc\u51faExcel\u5361\u987f\u600e\u4e48\u529e\uff1f\u5982\u4f55\u4f18\u5316\u5bfc\u51fa\u6027\u80fd\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   Win10\u4ee5\u592a\u7f51\u672a\u8bc6\u522b\u914d\u7f6e\u600e\u4e48\u529e \u4ee5\u592a\u7f51\u672a\u8bc6\u522b\u914d\u7f6e\u7684\u89e3\u51b3\u65b9\u6cd5\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>ExcelJs\u5bfc\u51faExcel\u5361\u987f\u600e\u4e48\u529e\uff1f\u5982\u4f55\u4f18\u5316\u5bfc\u51fa\u6027\u80fd\uff1f \u5404\u4f4d\u5c0f\u4f19\u4f34\u4eec\uff0c\u5927\u5bb6\u597d\u5440\uff01\u770b\u770b\u4eca\u5929\u6211\u53c8\u7ed9\u5404\u4f4d\u5e26\u6765\u4e86\u4ec0\u4e48\u6587\u7ae0\uff1f\u672c\u6587\u6807\u9898\u662f\u300aExcelJs\u5bfc\u51faExcel\u5361\u987f\u600e\u4e48\u529e\uff1f\u5982\u4f55\u4f18\u5316\u5bfc\u51fa\u6027\u80fd\uff1f\u300b\uff0c\u5f88\u660e\u663e\u662f\u5173\u4e8e\u6587\u7ae0\u7684\u6587\u7ae0\u54c8\u54c8\u54c8\uff0c\u5176\u4e2d\u5185\u5bb9\u4e3b\u8981\u4f1a\u6d89\u53ca\u5230\u7b49\u7b49\uff0c\u5982\u679c\u80fd\u5e2e\u5230\u4f60\uff0c\u89c9\u5f97\u5f88\u4e0d\u9519\u7684\u8bdd\uff0c\u6b22\u8fce\u5404\u4f4d\u591a\u591a\u70b9\u8bc4\u548c\u5206\u4eab\uff01 exceljs\u5e93\u5bfc\u51faexcel\u5361\u987f\uff1f \u5728\u4f7f\u7528exceljs\u5bfc\u51faexcel\u6587\u4ef6\u65f6\uff0c\u8bbe\u7f6e\u7279\u5b9a\u5217\u53ef\u7f16\u8f91\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u5bfc\u51fa\u901f\u5ea6\u53d8\u6162\u7684\u95ee\u9898\u3002\u672c\u6587\u5c06\u63a2\u8ba8\u4e00\u4e9b\u4f18\u5316\u5bfc\u51fa\u6027\u80fd\u7684\u65b9\u6cd5\uff1a \u6279\u91cf\u64cd\u4f5c\uff1a\u907f\u514d\u9010\u4e2a\u5355\u5143\u683c\u8bbe\u7f6e\u4fdd\u62a4\u548c\u89e3\u9501\uff0c\u800c\u662f\u6279\u91cf\u64cd\u4f5c\u3002\u793a\u4f8b\uff1a const unlockColumns = [6, 7, 8, 9, 12]; sheet.columns.forEach((col, colNumber) =&amp;gt; { if (unlockColumns.includes(colNumber + 1)) { \/\/ \u6307\u5b9a\u7279\u5b9a\u5217 col.eachCell((cell, rowNumber) =&amp;gt; { if (rowNumber !== 1) { \/\/ \u8df3\u8fc7\u6807\u9898\u884c cell.protection = { locked: false }; } }); } }); \u4f7f\u7528\u6a21\u677f\uff1a\u9884\u5148\u521b\u5efa\u6a21\u677f\u6587\u4ef6\uff0c\u8bbe\u7f6e\u597d\u6240\u9700\u4fdd\u62a4\u548c\u89e3\u9501\u8bbe\u7f6e\uff0c\u7136\u540e\u5c06\u6570\u636e\u5199\u5165\u6a21\u677f\u3002\u8fd9\u6837\u505a\u53ef\u4ee5\u51cf\u5c11\u52a8\u6001\u8bbe\u7f6e\u4fdd\u62a4\u7684\u5f00\u9500\u3002 \u4f18\u5316\u4ee3\u7801\u7ed3\u6784\uff1a\u907f\u514d\u8fc7\u5ea6\u5d4c\u5957\u548c\u5197\u4f59\u4ee3\u7801\uff0c\u4f7f\u5176\u66f4\u52a0\u7b80\u6d01\u9ad8\u6548\u3002 \u4ee5\u4e0a\u5c31\u662f\u300aExcelJs\u5bfc\u51faExcel\u5361\u987f\u600e\u4e48\u529e\uff1f\u5982\u4f55\u4f18\u5316\u5bfc\u51fa\u6027\u80fd\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01 Win10\u4ee5\u592a\u7f51\u672a\u8bc6\u522b\u914d\u7f6e\u600e\u4e48\u529e \u4ee5\u592a\u7f51\u672a\u8bc6\u522b\u914d\u7f6e\u7684\u89e3\u51b3\u65b9\u6cd5<\/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-53530","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53530","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=53530"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53530\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}