Java 编辑删除Excel中的命名区域

Java 编辑删除Excel中的命名区域

回复
  • 史梓馨用户
    [[{"txt": "\u4ee5\u4e0b\u7ecf\u9a8c\u5185\u5bb9\u5206\u4eab\u901a\u8fc7Java\u7a0b\u5e8f\u6765\u7f16\u8f91\u53ca\u5220\u9664Excel\u4e2d\u5df2\u6709\u547d\u540d\u533a\u57df\u7684\u65b9\u6cd5\u3002"}], [{"txt": ["\u5de5\u5177/\u539f\u6599"]}, {"txt": "Free Spire.XLS for Java\uff08\u514d\u8d39\u7248\uff09"}], [{"txt": ["jar\u83b7\u53d6\u53ca\u5bfc\u5165\uff1a"]}, {"txt": "\u901a\u8fc7e-iceblue\u5b98\u7f51\u4e0b\u8f7d\u5305\uff0c\u5e76\u89e3\u538b\u5c06lib\u6587\u4ef6\u5939\u4e0b\u7684jar\u6587\u4ef6\u5bfc\u5165java\u7a0b\u5e8f\u3002\u5982\u4e0b\u5bfc\u5165\u6548\u679c\uff1a"}, {"img": ["https://exp-picture.cdn.bcebos.com/1d735518512c8cf1349fc480c384cde34a2c468c.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}], [{"txt": ["Java\u4ee3\u7801\u793a\u4f8b"]}, {"txt": "import com.spire.xls.*;\u00a0 import com.spire.xls.core.INamedRange;\u00a0 \u00a0 public class ModifyNamedRange {\u00a0 \u00a0\u00a0\u00a0 public static void main(String[] args) {\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 //\u521b\u5efa\u5b9e\u4f8b\uff0c\u52a0\u8f7d\u6d4b\u8bd5\u6587\u6863\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Workbook wb = new Workbook();\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 wb.loadFromFile(\"NamedRange1.xlsx\");\u00a0 \u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u83b7\u53d6\u5de5\u4f5c\u8868\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Worksheet sheet = wb.getWorksheets().get(0);\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 //\u83b7\u53d6\u5168\u5c40\u547d\u540d\u533a\u57df\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 INamedRange namedRange = wb.getNameRanges().getByName(\"Range1\");\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 //\u83b7\u53d6\u5c40\u90e8\u547d\u540d\u533a\u57df\uff08\u5bf9\u5c40\u90e8\u547d\u540d\u533a\u57df\u8fdb\u884c\u76f8\u5173\u64cd\u4f5c\uff09\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 //INamedRange namedRange1 = sheet.getNames().getByName(\"Range1\");\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 namedRange.setName(\"NewRange\");//\u4fee\u6539\u533a\u57df\u540d\u79f0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 namedRange.setRefersToRange(sheet.getCellRange(\"C2\"));//\u4fee\u6539\u5355\u5143\u683c\u5f15\u7528\u533a\u57df\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 namedRange.setVisible(false);//\u9690\u85cf\u547d\u540d\u533a\u57df\u540d\u79f0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 //wb.getNameRanges().remove(\"Range2\");//\u5220\u9664\u547d\u540d\u533a\u57df\u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 //\u4fdd\u5b58\u6587\u6863\u00a0 \u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0wb.saveToFile(\"ModifyNamedRange.xlsx\");\u00a0 \u00a0\u00a0\u00a0 }\u00a0 }"}, {"txt": "\u547d\u540d\u533a\u57df\u7f16\u8f91\u7ed3\u679c\uff1a"}, {"img": ["https://exp-picture.cdn.bcebos.com/8db0c6a72633488422dba99fddee7b7f870e458c.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1", "https://exp-picture.cdn.bcebos.com/4a6d48ee7b7f860e884d074777f5ee0d3bcebe8c.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}]]
    2024-11-22
    1楼
    回复

参与评论

游客评论不支持回复他人评论内容,如需回复他人评论内容请