简体   繁体   English

如何防止在c#中重命名excel表

[英]how to prevent the rename excel sheet in c#

I am getting the reference error while saving the sheet because the existing Sheet name was RENAMED.保存工作表时出现参考错误,因为现有工作表名称已重命名。 So please guide to avoid the user to change the Sheet actual name or even though the user RENAME it, it will be renamed back to ORIGINAL name when the time of SAVEING data/Reload the page/Save changes.所以请指导避免用户更改工作表的实际名称,或者即使用户重命名它,当保存数据/重新加载页面/保存更改时,它也会被重命名回原始名称。

Kindly help on this.请对此提供帮助。

Thanks, Sesha谢谢,塞莎

I believe that you have several options here.我相信你在这里有几个选择。 You can store the sheet names of the worksheets in a xlVeryHidden sheet, and simply rename the sheets on a Workbook after save event.您可以将工作表的工作表名称存储在 xlVeryHidden 工作表中,并在保存事件后简单地重命名工作簿上的工作表。

https://msdn.microsoft.com/EN-US/library/office/ff836466.aspx https://msdn.microsoft.com/EN-US/library/office/ff836466.aspx

You can also simply reference the code names of the worksheets, which the user will not be able to change if you lock the VBA project.您还可以简单地引用工作表的代码名称,如果您锁定 VBA 项目,用户将无法更改这些代码名称。

https://msdn.microsoft.com/EN-US/library/office/ff837552.aspx https://msdn.microsoft.com/EN-US/library/office/ff837552.aspx

But all of this would require more detail from you regarding what you need.但是,所有这些都需要您提供有关您需要的更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM