tags:

views:

227

answers:

5

I have a requirement to export the results of a SQL query to excel. I am currently exporting it into 2007 format, but everything I have found will only run in a x86 enviroment. The web site where the export is to take place is running on a x64 version of IIS.

Changing IIS to run x86 is not an option. My current solution is to save the export request to a DB, and write a windows service that can run in x86 and use that service to process the request.

I have started to look at the Open XML Format SDK 2.0 as a possible better solution.

Has anyone got any experence that would lend to a native .NET solution.

FYI: My budget is $0.00 so buying a tool is a no-go.

+1  A: 

Personally from an ASP.NET application standpoint I have found that using XML and XSLT to go into the Excel XML format is the most effective, and really trouble free way to go. There are no costs involved, and once you get the hang of it, it is really quick!

In addition to that, I'm personally strongly against any form of automation to accomplish that kind of task.

Mitchel Sellers
A: 

I agree with Mitchel Sellers. Another way is create a simple html document with table, the excel will quite accept.

Example:

<html><body>
<table>
<tr><td>First column</td><td>Second column</td></tr>
<tr><td>Value of first row in first column</td><td>Value of first row in second column</td></tr>
<tr><td>Value of second row in first column</td><td>Value of secondrow in second column</td></tr>
</table>
</body></html>
TcKs
A: 

Mike, do you have any example I can look at? Exporting to Excel isn't something I have had much call foor ( None really ), so any head start would be nice.

TcKs, I tried the Html route and didn't much care for the way excel complained about the file format of html not being the expected .xls(x) format. I'm exporting for Sales guys, so the less messages thay have to wade through, ( and as a result questions I have to anyswer ), the better.

A: 

The simplest way that worked well for me is to create the Excel file in the correct format with one row of data.

Then save the file in html format and use it as a template for the actual data.

There is some metadata included that will automatically start Excel when doubleclicking the generated html file.

I had to go this way because we use Excel 2002 and 2003 which have no open file format.

VVS
A: 

Have a look at: http://www.codeproject.com/KB/office/excelxmlspreadsheet.aspx

I think we modelled an inhouse solution from this.

dragonspeed