The project I'm working on is to replace the Excel COM object with a .NET COM wrapper. This will then allow for 3rd party spreadsheet applications (like OpenOffice) to emulate Excel for 3rd party applications that use Excel's API.
Now, I know AutomateIT has already started doing this, but I feel .NET is a better platform for developing this on, since it now becomes rather easy to implement this library on Linux platforms (thanks to projects like Wine, Mono and DotGNU.)
So far, I have suceeded with wrapping a few of the objects, but I'm having a particularly hard time with default properties in any .NET language.
For example, let's say that I have the following property defined in VB.NET, and have the classes DefaultProperty pointed at this (this is a function from a class named CollectionBase, which is what I'm using as a base for all collections I define):
Public ReadOnly Property Item(ByVal index As Object) As Object
Dim i As Integer = 0
If (index.GetType().Name = "Int16") Or (index.GetType().Name = "Int32") Then
Dim indexValue As Integer = Integer.Parse(index.ToString())
For Each key As String In objColl.Keys
If i = (indexValue - 1) Then
i += 1
ElseIf index.GetType().Name = "String" Then
Catch e As Exception
If I do the following code in a WSH batch file: Set wb = Application.Workbooks.Item(1)
It will return the first workbook in the collection. But, if I do: Set wb = Application.Workbooks(1)
It will give a scripting exception.
If you do the same two commands using the original Excel COM object, they both do exactly the same thing: return the first workbook.
I have tried doing the above, as well as defining default properties in C# code (by defining the "this[object index]" property)...but the WSH script still doesn't work.
Does anyone have suggestions on how I can get "Set wb = Application.Workbooks(1)" to work from WSH through my implementation of the Excel COM object?