EPPLUS - Rename Cell

旧时模样 提交于 2019-12-11 01:22:01

问题


I'm using EPPLUS to build custom Excel spread sheets. One functionality that I'm missing is to change the name of a cell. Is this somehow possible with EPPLUS? If not are there any other ways of doing it?


回答1:


Suppose that book is your workbook and sheet is your worksheet. Let try this code snippet

var cell = sheet.Cells["C2"]; // Cell or Range you want to name
sheet.Names.Add("The_Name_Here", cell);

The name will be added to sheet. If you want to access the name in the whole workbook, try:

var cell = sheet.Cells["C2"]; // Cell or Range you want to name
book.Names.Add("The_Name_Here", cell);

Depend on your need the scope of the name can be sheet.Names or book.Names. I don't know how to modify an existing name but sure that 1 cell/range may have multiple names.



来源:https://stackoverflow.com/questions/13724482/epplus-rename-cell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!