Wiki Link: [discussion:3225]
Export a SQL View to Excel 2007 file 

Apr 11 2010 at 6:16 PM
I am some what new to the C# . NET world so please be gentle and I apologize in advance if I am posting this in the wrong place, but I am happy to be on board. Is there a modern way using LINQ are some of Microsoft's wonderful .NET frameworks to create a Console Application that will connect to a View in Microsoft SQL server and write that to an Excel 2007 file are even a CSV.

Specifically, I need to create multiple reports that pull their data from a view created for each report and save it to the local disk. Currently I am using windows task scheduler to run a C# Console Application I created to run every day at 600 AM and to create the Excel Files and overwrite the previous days excel files. These file are posted on a Web Server that is accessible to the Public view a Hyperlinks on the Web Page. This Program creates several 2003 Excel files (Report1 from View Report1 and Report2 from View2) and saves them to Web Servers local disk. I use a View so I can easily add and filter data without having to modify the program.

The excel 2007 format creates a much smaller file than its Excel 2003 equivalent. I have tried setting up a Job to export an Excel file in the SQL Server, but its not reliable and from the forums that appears to be a common problem.

I again apologize in advance if my wording and key terms are wrong causing confusion, or if I posted this in the wrong place.

Page view tracker