0

I'm working with a template where sheet names might change, but codenames will not. Is there a way to retrieve the codename of an Excel sheet in C#?

shCodeName = SH_parent.CodeName; does not seem to work, although shName = SH_parent.Name; works just fine

//Definition of SH_parent Excel.Worksheet SH_parent;

//Loading SH_parent

            foreach (Excel.Name N in WB.Names)
            {
                if (!N.Name.Contains("!"))
                {
                    //GLOBAL
                    string SH_Name = N.RefersTo.ToString().Split('!')[0].Replace("=", "").Replace("'", "");
                    SH_parent= WB.Worksheets[SH_Name];
                }
                else
                {
                    //SHEET
                    SH_parent = N.Parent;
                }
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Dumitru Daniel
  • 571
  • 4
  • 19

0 Answers0