I am using office 2007 excel work sheet function in c# code. VS2010 issues this warning
Warning 3 Ambiguity between method 'Microsoft.Office.Interop.Excel._Worksheet.Activate()' and non-method 'Microsoft.Office.Interop.Excel.DocEvents_Event.Activate'. Using method group. D:\EXLANEDB01p\dev\libraries\EXCEL\Excel.cs 531 95 EXCEL
How do I resolve this ? the call is
xSheet.Activate(); 
where xSheet passed as ref in the call as
ref Microsoft.Offic开发者_开发技巧e.Interop.Excel.Worksheet xSheet
You need to disambiguate the Activate name. Within the Worksheet interface, Activate is either a method (if looked at as a _Worksheet object) or an event (if looked at as a DocEvents_Event object).
Cast your object to Microsoft.Office.Interop.Excel._Worksheet first then call Activate().
((Microsoft.Office.Interop.Excel._Worksheet)xSheet).Activate();
Or declare a new _Worksheet variable and use that within your method.
_Worksheet sheet = xSheet;
sheet.Activate();
Otherwise you could change your method declaration to take a reference to a _Worksheet instead of a Worksheet as well as all associated declarations.
void MyMethod(ref Microsoft.Office.Interop.Excel._Worksheet xSheet)
{
    // ...
}
// usage:
_Worksheet sheet = new Worksheet();
MyMethod(ref sheet);
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论