Solved

c# dump sql queries to excel

Posted on 2006-10-28
3
901 Views
Last Modified: 2008-03-17
I need to grab multiple queries that do not relate to each other at all and want to have them dump into an excel spreadsheet or word.

I want to ensure I go about doing it the best way.

I didn't really want to reference excel because of multiple excel versions my customers may have, but I really don't think I have a choice.

Any thoughts and/or ideas?

0
Comment
Question by:bman9111
3 Comments
 
LVL 35

Expert Comment

by:Raynard7
ID: 17826920
Well,

I'd suggest that if you do not want to use multiple excel libaries then you save your data as .csv - and comma delimit everything this way that anyone with a spreadsheeting program will be able to open the result of your sql queries.  it just means you may have multiple files.

Otherwise it is awkward to include all the different libraries for excel and you may also get into licencing problems if you have to grab these for multiple clients.

Similarly you may be able to dump them into a rtf file,

then you can specifiy your formatting so they look acceptable - ie pad your values and dump them into a table.

this all depends on your eventual purpose.  Another approach that I have seen work quite well is to dump your data into xml and have an xsl style sheet work on your data so anyone with a web browser can see your neatly formatted tables - and can copy them to excel as required.

Alternativley you could just preformat them in c# and use an open source pdf libary and create a pdf for each of your queries.
0
 
LVL 8

Author Comment

by:bman9111
ID: 17827141
can you post code to dump a query to excel and to possible do the dump into xml and have an xsl style sheet that you are suggesting?
0
 
LVL 4

Accepted Solution

by:
Jigit earned 500 total points
ID: 17832930
One can write to Excel file using OLEDB connection independently on Office version:
http://www.developerfusion.co.uk/forums/thread/109392/#109392
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question