更新时间:2023-12-05 17:15:40
使用intreop库的另一种替代方法是 http://code.google.com/p/excellibrary/,它不需要您安装excel或excel.dll并将其注册到要安装它的计算机或服务器上.>
I am trying to open an Excel file from my C# code.
workBook = workBooks.Open(fileName, //filename
0, //updatelinks
true, //readonly
5, //format
"", //password
"", //WriteResPassword
true, //IgnoreReadOnlyRecommended
XlPlatform.xlWindows, //Origin
"\t", //Delimiter
false, //Editable
false, //Notify
0, //Converter
true, //AddToMru
1, //Local
0); //CorruptLoad
I see that the code hangs at workBooks.Open if the excel has some error within it. I have kept the display property to true and that is when I noticed that there is an error in the excel. On further investigation I got to know that the error is caused due to some vba code in the excel which is failing. My requirement is how do I get my C# code to be notified about this, so that it can ignore the error within the file or ignore the file itself?
Another alternative to using the intreop library is http://code.google.com/p/excellibrary/ which doesn't require you to have excel or the excel.dll installed and registered to your machine or server that you are putting it on.