<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.developerdotstar.com/community" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>developer.* Blogs - Lessons Learned Automating Excel from .NET - Comments</title>
 <link>http://www.developerdotstar.com/community/automate_excel_dotnet</link>
 <description>Comments for &quot;Lessons Learned Automating Excel from .NET&quot;</description>
 <language>en</language>
<item>
 <title>VSTO Envy</title>
 <link>http://www.developerdotstar.com/community/automate_excel_dotnet#comment-7317</link>
 <description>&lt;p&gt;Thank you for providing this additional info, Trevor. It sounds like a worthy alternative. However, I have a strong doubt that this solution would have worked for my client&#039;s company, which was still on Office 2000 and not planning to upgrade anytime soon. The first version of my solution was early bound, and I had to rewrite it to be late bound when it did not test well with Office 2000. Converting from early bound to late bound was relatively straightforward, but I shudder to think that I would have had to do a near-total rewrite if I had started with VSTO, which I had not heard of at the time (and which I am only assuming would have backwards compatibility problems with Office 2000--though I would be willing to be money that it does since Microsoft has a history of being obnoxious about driving Office upgrades with their Office development hook-ins).&lt;/p&gt;
&lt;p&gt;Anyway, I don&#039;t mean to crap on your suggested solution, Trevor. I appreciate it. If the circumstances are right, VSTO sounds like a great option, and one I&#039;d like to explore further for future projects.&lt;/p&gt;
&lt;p&gt;Dan&lt;/p&gt;
</description>
 <pubDate>Tue, 20 Mar 2007 11:22:52 -0700</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">comment 7317 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>VSTO</title>
 <link>http://www.developerdotstar.com/community/automate_excel_dotnet#comment-7315</link>
 <description>&lt;p&gt;If you need to couple .NET to Excel or any of the Office suite of applications, I would highly recommend using VSTO (Visual Studio Tools for Office) instead of the above techniques. When you install VSTO, you get a series of project templates that start you off working directly with, say, an Excel spreadsheet as part of your application. You can then use the spreadsheet (or Word doc) as a front-end to do just about anything you want. At my current job I had to create a spreadsheet that allowed a user to provide a customerID, click a button, and return a history of invoice summaries that had to populate a range. I wrote it all in C# just as if I were using a Windows Form. It was quite easy. The only hurdle I see is that if you have to deploy a VSTO application to a client&#039;s machine (or throughout an office) then you have to go through extra hoops including VSTO and some dependent assemblies in your MSI installer. Plus you need to set some security policy to grant execution rights on the client machine to the required assemblies.&lt;/p&gt;
&lt;p&gt;But in terms of the development itself, I found VSTO to be much easier and quicker because it allowed me to use everything natively in .NET. All of the COM+ interop is wrappered for you.&lt;/p&gt;
</description>
 <pubDate>Tue, 20 Mar 2007 10:04:25 -0700</pubDate>
 <dc:creator>trevor.conn</dc:creator>
 <guid isPermaLink="false">comment 7315 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Wrapping COM with COM</title>
 <link>http://www.developerdotstar.com/community/automate_excel_dotnet#comment-7242</link>
 <description>&lt;p&gt;Kalpesh, I don&#039;t think your suggestion to implement the needed Excel/Office functionality in a VB 6 DLL is stupid at all. I think it would work well, and I still have fond feelings for VB 6. However, I suspect that in a larger organization, or in a consulting situation, there could be managers or others who would not want to introduce VB 6 code into a solution for fear that they would have trouble maintaining it. That would depend on the situation, though...&lt;/p&gt;
&lt;p&gt;Thanks,&lt;br /&gt;
Dan&lt;/p&gt;
</description>
 <pubDate>Wed, 14 Mar 2007 15:27:07 -0700</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">comment 7242 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Other way to automate excel</title>
 <link>http://www.developerdotstar.com/community/automate_excel_dotnet#comment-7241</link>
 <description>&lt;p&gt;I havent done any office automation using .net. However, I feel, it will be better to create a COM component using VB6, which does all the work expected from the application&lt;/p&gt;
&lt;p&gt;This COM component can be called from c# or vb.net. So, one need not go through reflection &amp;amp; optional parameter thing, variant. Also, VB code will do the cleanup of objects instantiated (e.g. set myrange = nothing)&lt;/p&gt;
&lt;p&gt;How about VSTO? Does it do any better?&lt;br /&gt;
Hope this is a good suggestion &amp;amp; not a stupid one.&lt;/p&gt;
</description>
 <pubDate>Wed, 14 Mar 2007 14:17:20 -0700</pubDate>
 <dc:creator>Kalpesh</dc:creator>
 <guid isPermaLink="false">comment 7241 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Goes for alll of Office</title>
 <link>http://www.developerdotstar.com/community/automate_excel_dotnet#comment-7215</link>
 <description>&lt;p&gt;These are great tips that apply to the whole office suite. I recently had the pleasure of automating Word and PowerPoint. Unfortunately I wrote the whole thing in C#. I firmly agree with Tip #1. Never ever automate Office if you can find another way. With Excel at least you have the option of dumping the whole thing to a CSV and then manipulating the data. The one exception is PowerPoint which should never ever be touched by code, full stop. PowerPoint is the cistern of the Office automation sewer. No third-party is going to help you there.&lt;/p&gt;
</description>
 <pubDate>Tue, 13 Mar 2007 15:12:13 -0700</pubDate>
 <dc:creator>kevinDwhite</dc:creator>
 <guid isPermaLink="false">comment 7215 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Chill</title>
 <link>http://www.developerdotstar.com/community/automate_excel_dotnet#comment-6992</link>
 <description>&lt;p&gt;My friends at Microsoft aren&#039;t &quot;stupid bollockers&quot;. Instead, they are often people who were excluded from those universities who developed the culture of computing elegance by their parents&#039; finances and who, like an older generation of IBM employees, got some dignity out of a full time professional job from a man, Gates or Watson, who didn&#039;t care about their having a fancy education.&lt;/p&gt;
&lt;p&gt;Gates made a decision to protect his intellectual property in the shark tank which then and now is the American economy, a thieves&#039; economy, by using binary and proprietary formats, because he saw people lose their shirts in the 1970s to men who smiled and stole.&lt;/p&gt;
&lt;p&gt;This site is not a football match, mate, nor is real software development, either proprietary or open. You want to fight, see me on usenet.&lt;/p&gt;
&lt;p&gt;Not here.&lt;/p&gt;
</description>
 <pubDate>Thu, 08 Mar 2007 18:26:42 -0800</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">comment 6992 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Well, all this shows how</title>
 <link>http://www.developerdotstar.com/community/automate_excel_dotnet#comment-6953</link>
 <description>&lt;p&gt;Well, all this shows how crap the Microsoft binary formats are. If these stupid bollockers just used a nice text based programming interface in Unix spirit, let us say Excel listening on  a socket, accepting text &quot;messages&quot;, everything would be 100x easier.&lt;br /&gt;
Hell to them, piece of Microsoft piss.&lt;/p&gt;
</description>
 <pubDate>Thu, 08 Mar 2007 01:06:13 -0800</pubDate>
 <dc:creator>Guest</dc:creator>
 <guid isPermaLink="false">comment 6953 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Alternatives to calling Excel</title>
 <link>http://www.developerdotstar.com/community/automate_excel_dotnet#comment-6933</link>
 <description>&lt;p&gt;An incredible story of the effort needed to communicate from .Net to an old and very complex COM object, Dan.&lt;/p&gt;
&lt;p&gt;I have another suggestion. If you&#039;re calling Excel to do trivial computations, to allow the user to work on a spreadsheet in your GUI, consider creating your own version of Excel.&lt;/p&gt;
&lt;p&gt;The main problems:&lt;/p&gt;
&lt;p&gt;(1) Restricting the &quot;language&quot; of what can be entered in a cell to a subset of what is supported by Excel and which you feel comfortable compiling&lt;/p&gt;
&lt;p&gt;(2) Solving the problem of recalculating the linked cells in a spreadsheet by finding the top of the &quot;tree&quot; of computations and working downward. This was solved by Dan Bricklin in the first spreadsheet and his solution was patented, but it&#039;s fairly easy to reinvent, at least I think I did so in 1987 for a real estate appraisal system that presented the user with a spreadsheet of linked fields.&lt;/p&gt;
&lt;p&gt;If this sounds too complex, consider getting the free Open Office suite: this is written in modern code, it isn&#039;t COM, it presents no license or patent problems, and it MAY be easy to work with.&lt;/p&gt;
&lt;p&gt;Another solution would be &quot;arms length&quot;. Send keystrokes to an Excel application running in a different process entirely, save the result using these keystrokes, and parse it for the answer.&lt;/p&gt;
&lt;p&gt;The bottom line: if you define the problem (or it is defined for you) as &quot;I gotta use Excel as a COM object in a .Net application&quot; you&#039;re in for an interesting time, and as Dan has done, you need to use tryCatch a LOT.&lt;/p&gt;
&lt;p&gt;The need for wait loops to wait while Excel gets its act together implies for me a mini GUI to allow power users to control the timing and possibly progress screens. I say this because time-sensitive code can appear to hang a user&#039;s machine when it doesn&#039;t indicate what it is waiting for, and often needs to be tuned for different machines.&lt;/p&gt;
&lt;p&gt;The object2String() method found in the utilities library shipped with Build Your Own .Net Language and Compiler, btw, handles the problem of serializing (converting to character in my lexicon) any .Net object, and I found it useful in a .Net project that used variants from an Office application.&lt;/p&gt;
</description>
 <pubDate>Wed, 07 Mar 2007 17:51:04 -0800</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">comment 6933 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Lessons Learned Automating Excel from .NET</title>
 <link>http://www.developerdotstar.com/community/automate_excel_dotnet</link>
 <description>&lt;p&gt;Recently I had occasion to write a moderately complex component that used &quot;&lt;a href=&quot;http://en.wikipedia.org/wiki/OLE_Automation&quot; title=&quot;Windows COM OLE Automation&quot;&gt;automation&lt;/a&gt;&quot; (using the old fashioned COM term) to communicate with the Microsoft Office Excel application installed on the same computer. In this post I share several tips and tricks that may help you in your Excel automation adventures.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.developerdotstar.com/community/automate_excel_dotnet&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.developerdotstar.com/community/automate_excel_dotnet#comment</comments>
 <category domain="http://www.developerdotstar.com/community/taxonomy/term/16">.NET</category>
 <category domain="http://www.developerdotstar.com/community/taxonomy/term/22">VB.NET</category>
 <pubDate>Wed, 07 Mar 2007 17:26:21 -0800</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">717 at http://www.developerdotstar.com/community</guid>
</item>
</channel>
</rss>
