tags:

views:

512

answers:

1

I have a C# application where I am creating numerous Excel Files from Data in a Database. This part is working fine. However, my user asked if the sheet tab could be modified to reflect a field from the database. This sounds simple, however, when I try to reset the name, it tells me that it is read only and cannot be set. I have tried the following and it has not worked:

xlApp.Sheets[0].Range["A1"].Value = "NewTabName"; ALSO TRIED: xlApp.Name = "NewTabName";

I did a google search and saw some other approaches which did not work for me as well. And a few responses indicated that it is readonly and could not be done.

This seems like something that should be simple. How can I do it.

+4  A: 

You need to get access to the actual worksheet. Try something like:

  Microsoft.Office.Interop.Excel.Worksheet worksheet = (Worksheet)xlApp.Worksheets["Sheet1"];
  worksheet.Name = “NewTabName”;
mikemurf22
This worked great. Thanks much.
Steve Goedker