How to get the CodeName for Worksheet in Excel using VSTO

后端 未结 2 1959
南方客
南方客 2021-01-20 01:30

I did like this:

if (Excel._Application.ActiveWorkbook != null)
{
    List sheets = new List();
    foreach         


        
2条回答
  •  时光说笑
    2021-01-20 02:00

    In VSTO, the CodeName property is an infra-structure property that you should not be using from your code.

    From MSDN:

    This property supports the Visual Studio Tools for Office infrastructure and is not intended to be used directly from your code.

    Tell us what you are trying to accomplish, maybe there is an alternative way to do what you want.

    Also, I noted from your code that you are using an Excel Addin. You can try to check if the CodeName property returns what you expect if you use an Excel Document Customization instead of an Excel Addin.

    Update: In order for you to uniquely tag a worksheet you could use a GUID and set it as a custom property of the worksheet using Worksheet.CustomProperties.

提交回复
热议问题