如何将更改从同一文件保存到Excel文件

时间:2019-04-03 15:35:57

标签: c# excel interop

当我调用saveas()函数时,除最后保存的文件外,对文件所做的更改不会生效

xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Open(AppDomain.CurrentDomain.BaseDirectory + "my_file.xlsx");
xlWorkSheet = xlWorkBook.Worksheets["sheet1"];
for (int i = 0; i < 10; i++)
{
    xlWorkSheet.Cells[i, 1].value = i.ToString();
    xlWorkBook.SaveAs(AppDomain.CurrentDomain.BaseDirectory + i.ToString);
}
xlWorkBook.Close(false, Type.Missing, Type.Missing);
xlApp.Quit();

0 个答案:

没有答案