|
It would be useful to automate office 2003 (excel, word, powerpoint) from a silverlight application. It is possible, feasible even, but it is hard to find good information on how to do it.
I have found a few ways to automate office from silverlight.
I have chosen to use the Open XML SDK 2.0 as my primary solution with a limited implementation of the COM automation libraries for certain situations. Next I will outline the pros and cons of the methods I mentioned above and after that I will provide a simple walkthrough for using the Open XML SDK 2.0 from silverlight and a simple walkthrough for using COM automation and the dynamic type.
Open XML
I'm a big fan of OOXML. It's definitely not perfect, but it's a huge step forward from the office 2003 formats. You can take any .docx file or similar office file, change the extension to .zip and unzip it. They are all zip archives! Inside you'll find a folder system of .xml documents. So, at a fundamental level you can write a few text files, zip them, change the extension to .docx, and you've got a word document. For more information here is the wikipedia article and here is the ooxml specification. Above, I mentioned two different ways to automate Open XML: Through the Open XML SDK 2.0 and by using custom classes.
Open XML SDK 2.0
The open XML SDK 2.0 is a kit released by Microsoft you can use to automate excel through objects. You can download it here. Here is a simple code sample just so you can see what it looks like:
I like it because it feels like it's made to be used in C#. All the other methods seem like they were originally designed to be used with VB 6.0, so you end up adding a lot of unusual code to get it to work.
|