如何解决Excel应用程序中的问题 [英] How to solve the problem in Excel Application

查看:80
本文介绍了如何解决Excel应用程序中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在我的项目中使用excel应用程序.我正在使用excel模板并填充该excel工作簿并将其保存到新文件夹中,一切正常.在填充excel应用程序并将其保存为相同文件名后,它会询问您:是否要替换文件?如果单击否"按钮,则表示您要对Excel模板进行更改.谁能帮我解决这个问题.这是保存应用程序的代码:

Hi,

I am using excel application in my project. I am taking the excel template and filling that excel workbook and saving it into the new folder, it all works fine. After I am filling the excel application and saving that with the same file name it asks for: DO you want to replace the file?. If I click the no button it says that you want to make the changes to the Excel Template. Can anyone help me to solve this problem.Here is the code for saving the application:

excelWorkbook.SaveAs(@"D:\RiteFile\" + filename + ".xlsm");
               string path = @"D:\RiteFile\" + filename + ".xlsm";

               //excelApp.Visible = true;
               excelApp.UserControl = false;
               excelWorkbook.Close();
               excelApp.Workbooks.Close();
               excelApp.Quit();
               System.Runtime.InteropServices.Marshal.ReleaseComObject(excelWorkbook);
               System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
               excelWorkbook = null;
               excelApp = null;
               System.Diagnostics.Process.Start(path);

           }
       }
       catch (Exception ex)
       {
           //UserUtil.Message(ex.Message, this);
           excelApp.UserControl = false;
           //excelWorkbook.Close();
           excelApp.Workbooks.Close();
           excelApp.Quit();
           //System.Runtime.InteropServices.Marshal.ReleaseComObject(excelWorkbook);
           System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
           //excelWorkbook = null;
           excelApp = null;

       }



在此先感谢



Thanks in Advance

推荐答案

可能被设置为readonly属性....
may be readonly property is set to that ....



保存excel文件之前,添加以下行
excelApp.DisplayAlerts = false;

谢谢
kannan
www.steadfastglobal.com
Hi,
before saving the excel file, add the following line
excelApp.DisplayAlerts = false;

Thanks
kannan
www.steadfastglobal.com


这篇关于如何解决Excel应用程序中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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