如何保存工作表选项卡导出的名称c#

时间:2016-07-01 06:30:03

标签: c# excel winforms export-to-excel excel-interop

我有以下代码如何使用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();

enter image description here

0 个答案:

没有答案