This project has moved. For the latest updates, please go here.
/* taken from Tutorial06.csproj
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 void Tutorial06Main() { // Initialize Api COMObject Support LateBindingApi.Core.Factory.Initialize(); // start application Excel.Application application = new Excel.Application(); application.DisplayAlerts = false; // create new Workbook Excel.Workbook book = application.Workbooks.Add(); Excel.Worksheet sheet = (Excel.Worksheet)book.Worksheets[1]; Excel.Range range = sheet.Cells[1,1]; // Style is defined as Variant in Excel Type Library and represents
// as object in NetOffice
Excel.Style style = (Excel.Style)range.Style; // variant types can be a scalar type, another way to us is if (range.Style is string) { string myStyle = range.Style as string; } else if (range.Style is Excel.Style) { Excel.Style myStyle = (Excel.Style)range.Style; } // 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(this, "Done!", this.Text, MessageBoxButtons.OK,
MessageBoxIcon.Information); }

   See next: Tutorial07 - Invoker

Last edited Jan 5, 2012 at 9:47 AM by SebastianDotNet, version 8


No comments yet.