Click to See Complete Forum and Search --> : how to export a table to a excel file?


soclose
October 4th, 2008, 12:41 AM
Hi All. In Miscrosoft SQL Server 2005, could we export a table having data rows to a Excel file? If so, how do I? Pls share me.

ahoodin
October 4th, 2008, 12:55 AM
Well if you can export to csv you can import it into Excel.

TheCPUWizard
October 4th, 2008, 02:53 PM
Three approaches.

1) As Ahoodin stated, export as a CSV. Excell will open this.

2) Use CLR Procedures to Create a valid XLSX (2007 format) Spreadsheet. The file format for 2007 is the first time that it is documented and supported. The actual content is a combination of XML and Zipped Content.

3) Write a Client Application (Licensing typically prevents this being directly performed on the server) that uses the Office API (which requires that Excel be installed).

Also (although this is differerent:

4) Write your Excel Spreadsheet so that it queries the SqlDatabase....

Finally....

5) Generate random (or pattern progression) data, given sufficient time you will get a bit pattern that contains what you want.


Personally I would recommend #1 or #4.

I would be very cautious about taking approach #5. :eek: :eek: ;)

George1111
November 2nd, 2008, 06:09 AM
If you search for

"Export table to Excel"

in the "VB6 Programming" forum you will find a large number of examples

Heres one example from that search

http://support.microsoft.com/default.aspx?scid=kb;EN-US;247412

Also search for "Export Msflexgrid to Excel" as this is sometimes a nice stepping stone to getting data into Excel

ahoodin
November 2nd, 2008, 07:01 PM
George1111, FYI this thread was about a month old.

George1111
November 3rd, 2008, 07:17 AM
In Code Guru I am used to getting specific answers to problems - not generalities - some answers are just fantasic and save me hours of coding.

I take my hat off to the "gurus" who I dont even have the skill to polish their shoes.

BUT - I am a wonderful programmer if you show me how to do it first !

I find code examples useful and help me solve my problem a lot quicker than general comment about my problem

For some reason I felt the answers posted to the question didn't quite solve the question - helpful yes - but a little code is really what a person wants when they ask a simple question like this thread

The original post is only about 4 weeks old (go over to the VB6 forum where a thread started 11th July 2004 has been resurrected - you worry about 4 weeks - go pass some comment on a 4 year thread!)

The other point is that, some people actually search for answers to problems in the forums, before posting a new question. My contribution of a link to some fantastic code examples from Microsoft giving 5 or 6 ways of exporting to excel will one day be discovered by some newbee looking for code to do just this.

I find answers to my problems in threads which were posted back in 2003 - there's some amazing stuff inside Code Guru searches !

I guess its a balance of being cryptic or helpful

Perhaps I am being too helpful

I also notice that this thread has been read by a large number of viewers, which also confirms that people are interested in the answer to the question. In fact, about 100 extra viewings have take place since I posted my answer.

This tells me that more than the original poster of the thread have an interest in the question. I hope you all find the post helpful.

ahoodin
November 3rd, 2008, 12:35 PM
I am noting that it is most likely too late to help the original poster. Also CPUWizards last post was on the same day along with the other posts. I am not questioning your programming skill as I am unfamiliar with your resume.