Microsoft.Office.Interop.Excel having "bad value" as default parameters
I'm trying to use Microsoft.Office.Interop.Excel. It seems to load fine but when I try to use it, all the defaults parameters are not working. Here is a screenshot that shows all those bad values
Whenever I try to ommit them, the compiler tells me that the function needs more than 1 parameter.
This function is Open as in :
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
Workbook wb = excel.Workbooks.Open("ss.xlsx");
How can I use the default value for those 14 parameters?
EDIT I'm using C# 3.5 (2008) with Office 2010
Accepted Solution :
Type.Missing works I also had this issue http://support.microsoft.com/default.aspx?scid=kb;en-us;32开发者_运维知识库0369 The problem is that my windows is french but office is in english so hell breaks loose.
Solution is
CultureInfo ci = new CultureInfo("en-US");
System.Threading.Thread.CurrentThread.CurrentCulture = ci;
use System.Type.Missing
or System.Reflection.Missing.Value
for any parameters you want to ommit.
But it looks like you are using wrong (Lower) version Excel Interop to open "xlsx" (should use version 12 for office 2007 support)
Use Type.Missing for the optional parameters you don't want to set.
See: http://msdn.microsoft.com/en-us/library/dd264733.aspx and http://softwaresalariman.blogspot.com/2010/05/rudimentary-c-com-interop-client-for.html
精彩评论