Solved

c# dump sql queries to excel

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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