C#和Excel互操作问题,保存Excel文件不顺畅 [英] C# and Excel Interop issue, Saving the excel file not smooth

查看:194
本文介绍了C#和Excel互操作问题,保存Excel文件不顺畅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以打开和写入到Excel文件,但是当我试图通过传递的路径将其添加到文件保存,保存操作的保存对话框提示。我期待它的文件静静保存在指定的路径

I could Open and Write to the excel file, but when I try to save the file by passing a path to it, the save operation prompts with the Save dialog. I was expecting it to quitely Save the file at the specified path

中的代码如下:

excelApp.Save(exportToDirectory);
excelApp.Quit();

其中, exportToDirectory 是:C:\files\strings 。的.xlsx

where, exportToDirectory is: "C:\files\strings.xlsx".

PS:我已经检查的Excel版本和类似的问题。

PS: I have already checked with the excel version and similar issue.

感谢

推荐答案

您需要使用 Workbook.SaveAs 而不是 Application.Save

Excel.Application app = new Excel.Application();
Excel.Workbook wb = app.Workbooks.Add(missing);
...
wb.SaveAs(@"C:\temp\test.xlsx", missing, missing, missing, missing,
          missing, Excel.XlSaveAsAccessMode.xlExclusive,
          missing, missing, missing, missing, missing);

这篇关于C#和Excel互操作问题,保存Excel文件不顺畅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆