i'm trying to programmatically add sheets to a new excel document.
my expected output is sheets named 'test1-20' but instead i get 'Sheet1-19, test20'.
why doesn't this work?
Workbook workbook;
Application objExcel;
objExcel = new Application();
objExcel.Visible = false;
objExcel.DisplayAlerts = false;
for (var i = 0; i < worksheets.Count; i++)
{
workbook= objExcel.Workbooks.Add(Missing.Value);
var worksheet = (Worksheet)workbook.Worksheets.get_Item(i + 1);
worksheet.Name = string.Format("test{0}", i + 1);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…