jwcolby
jwcolby at colbyconsulting.com
Sat Jan 30 13:00:07 CST 2010
Mark, >The incredibly increased verbosity of the coding required already speaks of lower development speed. If you are talking about the full object specification - Microsoft.Office.Interop.Excel.Application You should be able to shorten that up by the USING statement. Once you do that you technically do not need to fully spec the thing. John W. Colby www.ColbyConsulting.com Mark Simms wrote: > Very interesting. John Walk once said he would go to his grave before coding > in VSTO. > > I'm interested in knowing if there are any performance "hits" compared to > native Excel/VBA when employing dot-net interop solutions. The incredibly > increased verbosity of the coding required already speaks of lower > development speed. >> // This bit shows the using statements you will need >> >> using Microsoft.Office.Interop.Excel; >> using Microsoft.Office.Tools.Excel; >> >> >> >> >> // This bit shows how to op an connection to Excel >> >> if (grdParts.RowCount > 0) >> { >> if (MessageBox.Show("Export Master Parts >> List?", "Export", MessageBoxButtons.YesNo, >> MessageBoxIcon.Question) == (DialogResult.Yes)) >> { >> this.Cursor = Cursors.WaitCursor; >> Int32 intPos = bsParts.Position; >> try >> { >> if (SaveChanges()) >> { >> >> Microsoft.Office.Interop.Excel.Application xlApp = new >> Microsoft.Office.Interop.Excel.Application(); >> >> Microsoft.Office.Interop.Excel.Workbook xlWB = >> xlApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet); >> >> Microsoft.Office.Interop.Excel.Worksheet xlWS = >> (Microsoft.Office.Interop.Excel.Worksheet)xlWB.Worksheets[1]; >> >> xlApp.Visible = true; >> >> xlWS.Cells[2, 6] = "Parts List "; >> xlWS.Cells[3, 6] = "Date " + >> DateTime.Now.ToLongDateString(); >> >> >> // This bit shows how to write comments to excel >> >> Microsoft.Office.Interop.Excel.Range nRange; >> >> nRange = >> (Microsoft.Office.Interop.Excel.Range)xlWS.Cells[intRowIndex >> + intRowIncrement, intColumnIndex - 11]; >> >> nRange.AddComment(strFullComments.Replace("\r", >> "")); >> >> nRange.Comment.Shape.TextFrame.AutoSize = true; >> >> >> >> >> // This but shows how to insert a column >> Range rng = (Range)xlWS.Cells[1,2]; >> Range column = rng.EntireColumn; >> >> column.Insert(XlInsertShiftDirection.xlShiftToRight, false); >> >> column.Insert(XlInsertShiftDirection.xlShiftToRight, false); >> >> >> // this bit shows how to save the sheet >> String strFileName = "C:\\McAfee >> Prd Report_" + >> DateTime.Now.ToLongDateString() + "-" + >> DateTime.Now.ToLongTimeString().Replace(":", "") + ".xls"; >> xlWS.SaveAs(strFileName, >> Type.Missing, Type.Missing, Type.Missing, Type.Missing, >> Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); >> > > >