C#Excel 2010中打开工作簿错误 [英] C# Excel 2010 Workbook Open error
问题描述
我们最近升级了从Excel 2007年到Excel 2010中,我们已经发现,现有的代码启动失败
We recently upgraded from Excel 2007 to Excel 2010, and we have found that existing code started failing.
异常消息:
Office检测这个文件有问题。为帮助保护您的
电脑这个文件不能打开。
Office has detected a problem with this file. To help protect your computer this file cannot be opened.
我们已追查这对我们打开该文件的行
We have traced this to the line where we open the file
excelApp.Workbooks.Open
打开手动将文件甚至当,受保护的视图消息框出现。
Even when opening the file manually, the Protected View Messagebox comes up.
我们如何工作的角落找寻此使用C#。
How can we work arround this using C#.
推荐答案
有一个在使用的 Application.FileValidation属性(Excel)中之前你的打开
语句。
Have a look at using Application.FileValidation Property (Excel) before your Open
statement.
返回或设置Excel如何将打开它们之前验证文件。
读/写
Returns or sets how Excel will validate files before opening them. Read/write
文件没有通过验证将在一个受保护的视图
窗口中打开。如果设置了FileValidation属性,该设置将
留在应用程序打开时,整个会议的效果。
Files that do not pass validation will be opened in a Protected View window. If you set the FileValidation property, that setting will remain in effect for the entire session the application is open.
您可以将其设置为枚举值之一 MsoFileValidationMode枚举
You can set it to one of the enum values in MsoFileValidationMode Enumeration
msoFileValidationDefault
msoFileValidationDefault
msoFileValidationSkip
msoFileValidationSkip
如果你的打开
语句之前将其设置为 msoFileValidationSkip
,它应该绕过检查
if you set it to msoFileValidationSkip
before the Open
statement, it should bypass the check.
类似
excelApp.FileValidation = MsoFileValidationMode.msoFileValidationSkip;
在OPEN语句之前。
before the open statement.
这篇关于C#Excel 2010中打开工作簿错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!