如何替换Excel中已经存在的文件 [英] How to replace already existing file in Excel
本文介绍了如何替换Excel中已经存在的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在使用以下语句保存文件.
但是问题是如果该文件已经存在,我希望在没有用户干预的情况下替换该文件.请帮助.
Hello All,
I am using the following statement to save file.
But the problem is if the file already exists i want that file to be replaced without user interupt.Please help.
newworkbook.SaveAs(
@"c:\test1.xls",
Excel.XlFileFormat.xlWorkbookNormal,
"",
"",
false,
false,
XlSaveAsAccessMode.xlNoChange,
XlSaveConflictResolution.xlUserResolution,
false,
false,
false,
true);
推荐答案
为什么不首先使用File.Delete删除它(如果存在)?或者检查文档以查看那些"false"值中是否有一个用于如果存在则覆盖"?
Why not just use File.Delete to delete it first if it exists ? Or check the docs to see if one of those ''false'' values is for ''overwrite if existing'' ?
这篇关于如何替换Excel中已经存在的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文