Solved

c# dump sql queries to excel

Posted on 2006-10-28
3
895 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now