EPPLUS-重命名单元 [英] EPPLUS - Rename Cell

查看:90
本文介绍了EPPLUS-重命名单元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用EPPLUS构建自定义Excel电子表格。我缺少的一项功能是更改单元格的名称。 EPPLUS是否可以通过某种方式实现?如果没有其他方法,可以这样做吗?

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?

推荐答案

假设那本书 是您的工作簿,工作表是您的工作表。让我们尝试一下此代码段

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);

根据您的需要,名称范围可以为 sheet.Names book.Names
我不知道如何修改现有名称,但请确保1个单元格/范围可能有多个名称。

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.

这篇关于EPPLUS-重命名单元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆