在DotNet中建立一个Excel Project(DotNet2003, Office2003, VSTO2), 更改Excel中的A1单元格的名字为celFirstName, 希望更改celFirstName的值时取得它的Name:   protected void ThisWorkbook_SheetChange(Object sh, Excel.Range Target)
  {
  if (Target != null)
  {
MessageBox.Show(Target.Name.ToString());
  }
  }编译后打开Excel且更改A1的值后显示"System.__ComObject", 为什么不是"celFirstName"?
怎样取得一个Cell或者Range的Name?

解决方案 »

  1.   

    //Get the excel object
    excel = Type.GetTypeFromProgID("Excel.Application");
    //Create instance of excel
    objApp_Late = Activator.CreateInstance(excel);
    //Get the workbooks collection.
    objBooks_Late = objApp_Late.GetType().InvokeMember( "Workbooks", 
    BindingFlags.GetProperty, null, objApp_Late, null );其余方法类似,用反射
      

  2.   

    MessageBox.Show(Target.Value2.ToString());
      

  3.   

    MessageBox.Show(Target.Application.ActiveCell.Text.Tostring());