Reflecting on Excel

| | Comments (0) | TrackBacks (0)
Gabhan Berry has some really interesting (and potentially useful!) stuff that mainly centres around programming with Excel. One of the most interesting entries is one regarding dealing with Optional parameters in the Excel object model when using C# (Optional Parameters are supported by the CLR and VB.net, but not by C#). Whilst reflection is pretty cool and using it to achieve a solution to the Excel object models fetish for optional parameters is quite clever, personally I'd go for a wrapper class that I'd written which gives a set of different method signatures to accommodate my needs. Compile time checking is well worth having and eliminating the subtle bugs that can have me banging my head against the wall for hours that using reflection in this way introduces is a winner any day.

The common consensus, although I have no statistics or timings to prove or disprove this, is that using reflection is slower as well. If, for example, you were automating Excel to produce output / read input (yes, there are better ways to do this!) that contained a large amount of data, I imagine this could begin to make a significant difference to performance. On the other hand, choosing against reflection purely because of this could be considered a premature optimisation.

Of course, the other answer is to just use VB.net rather than C# ;)

0 TrackBacks

Listed below are links to blogs that reference this entry: Reflecting on Excel.

TrackBack URL for this entry: http://www.robertwray.co.uk/mt/mt-tb.cgi/140

Leave a comment

About this Entry

This page contains a single entry by Rob published on February 21, 2008 5:15 PM.

Microsoft Fanboy? Hardly.. was the previous entry in this blog.

Loch Fyne and the National Minimum Wage is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.23-en