我有以下代码如何使用sheetname excel文件保存,请参阅下面的图像和代码,我想添加发票否,但显示错误
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
// app.Visible = true;
app.Workbooks.Add(@"E:\Excel Single Sheet\Invoice-INV68.xls");
app.Workbooks.Add(@"E:\Excel Single Sheet\Invoice-INV67.xls");
string path = @"E:\E:\Excel Single Sheet\New folder\";
int InvoiceNo = 221;
for (int i = 2; i <= app.Workbooks.Count; i++)
{
InvoiceNo++;
for (int j = 1; j <= app.Workbooks[i].Worksheets.Count; j++)
{
Microsoft.Office.Interop.Excel.Worksheet ws = app.Workbooks[i].Worksheets[j];
ws.Copy(app.Workbooks[1].Worksheets[1] + InvoiceNo);
}
}
app.Save();