Showing posts with label Office. Show all posts
Showing posts with label Office. Show all posts

Sunday, January 18, 2009

Converting Office 2007 Excel to XML using C#

Don't want Office 2007 installed on your web server to access Excel 2007 content?

Here is a Visual Studio C# solution that demonstrates how to read an Excel 2007 workbook, converting it to XML. You don't need Office 2007 installed in order to do this! Once Excel content is in XML format you can process it easier using transformations tools or other language code.

The solution code uses .NET 3.5 XML support and LINQ. The solution also contains an example console application that will take an Excel 2007 file name on the command-line and convert it to XML via the console. Everything should run out-of-the-box using an example Excel 2007 file that is included; just run the example application and accept the default file name to read.

The quickest way to learn how to use the ExcelReader class, and its options, is to examine the brief Program.cs file in PCarver.OfficeXml.ExampleExcel project. You an register for events to transform cell contents and ignore certain rows (see example code).

Download only the binary files for converting Excel to XML:

Click here for binaries/executables

Download the full Visual Studio Solution:

Click here for Visual Studio 2008 Solution

If you have any bug fixes or nice enhancements, please post a comment and let me know.

Information from Microsoft on these formats is found at:

http://msdn.microsoft.com/en-us/library/aa338205.aspx.

Can't RDP? How to enable / disable virtual machine firewall for Azure VM

Oh no!  I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore.  I did ...