Posted By: mitch | Apr 23rd, 2004 @ 1:42 AM
page 1 of 1
Comments: 7 | Views: 14693
I am using the Microsoft .NET Framework SDK v1.1. I am trying to add a reference to the Microsfot Excel Object Library.

Am I correct in assuming this is done by using the reference switch with csc? If it is possible to do with the framwork, what filename should I be passing?

Thanks,

Martin
Lwatson
Lwatson
One ugly mug...
Are you trying to message excel like the old COM days? If so I believe that you have to do so using com Interop ( because excel is still a COM application ). We have software in he field that does this every day.

Here is a little snippet of code ripped from one of my test apps that plays with excel extensively. I have not added any references to excel in the references section. I am using Late binding which may or may not be appropriate for you setup. We use late binding because the application needs to be able to run in systems where excel is not installed.

Formatting in this message editor is less than ideal but you should be able to get the point...
Please no flames about the inherant issues in this code I know they are many Its only from one of my test rigs folks....


Here goes

Dim ex As Object

Dim sh As Object

Dim iRatingIndex As Integer

For iRatingIndex = 0 To sCategories.GetUpperBound(0)

Dim _workbook As Object

Try

   ex = CreateObject("Excel.Application")

Catch trouble As Exception

   MsgBox(trouble.Message, MsgBoxStyle.Exclamation,    "Houston... we have a problem")

Exit Sub

End Try

ex.visible = True

ex.ScreenUpdating = False

' create the 26 worksheets

_workbook = ex.workbooks.add()

While ex.activeworkbook.worksheets.count < 26

   ex.workbooks.item("Book1").worksheets.add()

End While

Dim iIndex As Integer

' set the name of each worksheet

For iIndex = 1 To 26

   ex.workbooks.item("Book1").worksheets(iIndex).name = Me._worksheets(iIndex).Name

Next

jj5
jj5
Yeah. We got goth served.
Did you figure out that you need to create a COM interop assembly?

Check out the .NET Framework Type Library to Assembly Converter: tlbimp.exe

John.
Pubb
Pubb
Everybody Everybody!
You should try using the Office PIAs. More info about COM Interop.
tgraupmann
tgraupmann
tgraupmann
Is there a reason why you need to create an Excel object?

You can easily have your app output an Excel xml file.
page 1 of 1
Comments: 7 | Views: 14693