' taken from Tutorial06.vbproj
' The datatype Variant is not plain supported by .NET CLR but common in an 
' unmanaged COM Environment.
NetOffice mapped the type to object but you never
' have to fear you lost the COM Proxy management from NetOffice.
' ' See chapter2 in technical documentation for further info. ' Private Sub Tutorial06Main() ' Initialize Api COMObject Support LateBindingApi.Core.Factory.Initialize() ' start application Dim application As New Excel.Application() application.DisplayAlerts = False ' create new Workbook Dim book As Excel.Workbook = application.Workbooks.Add() Dim sheet As Excel.Worksheet = book.Worksheets(1) Dim range As Excel.Range = sheet.Cells(1, 1) ' Style is defined as Variant in Excel Type Library and represents
' as object in NetOffice
Dim style As Excel.Style = range.Style 'variant types can be a scalar type, another way to us is If (TypeName(range.Style) = "String") Then Dim myStyle As String = range.Style ElseIf (TypeName(range.Style) = "Style") Then Dim myStyle As Excel.Style = range.Style End If ' Name, Bold, Size are bool but defined as Variant and also
' converted to object
style.Font.Name = "Arial" style.Font.Bold = True style.Font.Size = 14 ' quit & dipose application.Quit() application.Dispose() MessageBox.Show(Me, "Done!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub

    See next: Tutorial07 - Invoker

Last edited Jan 5, 2012 at 10:19 AM by SebastianDotNet, version 6


No comments yet.