المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Excel interop issue



C# Programming
09-11-2009, 11:58 AM
HI
I am developing a .NET MyLib.dll to be exposed via COM to Excel.
In It there is a class called MyDotNetClass ( ComVisible is set to ture
and I have GUID attributer )
When I pass a Range to my AnyMethod and I want to get the FormulaR1C1Local
everything is thine.
When I want to call other method other than this ( including the getValue to get
the real valu conatined by the cells in that range, not its formula )
I have a lot of exception most of the same time.
Can you help me with that?
I already have a reference to Microsoft.Office.Interop.Excel library V12.0
for Excel 2007.

Thanks
Mn


// C# class
class MyDotNetClass
{
String AnyMethod( Microsoft.Office.Interop.Excel.Range aRange )
{
object[,] formula = (object[,])aRange.FormulaR1C1;
// I can get the formulas like CONCATENATE( A1,B1 ) or
// references like D14

// most of methods and properties thrown an exception

// I cannot even get the Value or call get_Value
// I ahve this excepion
// "Old format or invalid type library. (Exception from HRESULT:
// 0x80028018 (TYPE_E_INVDATAREAD)) System.SystemException
// {System.Runtime.InteropServices.COMException}

}
}

'VB CODE
Function MyFoo( aRange As Range) As String
Dim myLibObj As New MyLib
MyFoo = myLibObj.AnyMethod( aRange )
End Function