Solved

c# dump sql queries to excel

Posted on 2006-10-28
3
902 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: 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

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.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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