By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,694 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,694 IT Pros & Developers. It's quick & easy.

Export datagrid contents to EXCEL

P: n/a
I would like to export earnigs of employees from datagrid to EXCEL.

for example:
__________________________
|..name.............|..money...............|
-----------------------------------
|..John..............|..100$.................|
|..Mary.............|...150S...............|
-----------------------------------

Sum: 250$ (sum is a label)

I would like to export both of them : contents of grid and text of label.
By the most important for me is datagrid - is there any easy way?
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi Chreo!

"chreo" schrieb
I would like to export earnigs of employees from datagrid to EXCEL.


HOW TO: Transfer Data to an Excel Workbook by Using Visual Basic .NET
http://support.microsoft.com/default...b/306022/en-us

Cheers

Arne Janning
Nov 21 '05 #2

P: n/a
Chreo,

A datagrid holds no data, it shows data that is in an object.

Therefore it is almost impossible to transfer data from a datagrid to Excel.

Cor
Nov 21 '05 #3

P: n/a
Oh....datagrid holds no data? :(

So there won't be export to excel in my application :-)
Nov 21 '05 #4

P: n/a
>
So there won't be export to excel in my application :-)

When you want help than you have to show what kind of object the datagrid is
using to display the data. Can be a dataset, dataview, datatable, arraylist
etc. etc.

Assuming it is a windows form appliction what I assume because you did not
told what kind of datagrid it was. Windows form is than default in this
newsgroup.

Cor
Nov 21 '05 #5

P: n/a
I use Private Sub to fill datagrid.
I create connection, command, dataadapter and dataset.
But these are local objects and they live as long as procedure lives - am I
right? :)
So I thought that values stay in datagrid but these data-objects don't exist
anymore.
Dim conZarobki As New SqlClient.SqlConnection
Dim comWyswietlZarobki As New SqlClient.SqlCommand
Dim daZarobki As New SqlClient.SqlDataAdapter
Dim dsZarobki As New DataSet
Dim Miesiac As Date
Miesiac = datData.Value
conZarobki.ConnectionString = FormLogowanie.strPolaczenie

With comWyswietlZarobki
..Connection = conZarobki
..CommandText = "SELECT * FROM " & "POKAZ_ZAROBEK_DWD" & "(@LOGIN,@DATA)"
..Parameters.Add("@LOGIN", SqlDbType.VarChar)
..Parameters.Add("@DATA", SqlDbType.SmallDateTime)
..Parameters(0).Value = cmbLogin.Text
..Parameters(1).Value = Miesiac
End With

daZarobki.SelectCommand = comWyswietlZarobki
daZarobki.Fill(dsZarobki, "ZAROBKI")

dgrZarobki.DataSource = dsZarobki.Tables("ZAROBKI")
Nov 21 '05 #6

P: n/a
Had the same problem a few days ago.

I suggest you start by reading the following MSDN documentation:
http://support.microsoft.com/default...b;en-us;247412
and check the REFERENCES at the bottom for document#: 306022, which is
better and more extensive.

good luck!

"chreo" <ch***@gazeta.pl> a écrit dans le message de news:
d5**********@inews.gazeta.pl...
I would like to export earnigs of employees from datagrid to EXCEL.

for example:
__________________________
|..name.............|..money...............|
-----------------------------------
|..John..............|..100$.................|
|..Mary.............|...150S...............|
-----------------------------------

Sum: 250$ (sum is a label)

I would like to export both of them : contents of grid and text of label.
By the most important for me is datagrid - is there any easy way?

Nov 21 '05 #7

P: n/a
Chreo,

This is a link to a page from Scorpion.
Who I saw the last days again in this newsgroups.

http://www.kjmsolutions.com/datasetarray.htm

I hope this helps

Dobry Wieczór

Cor
Nov 21 '05 #8

P: n/a
THANX - I THINK THAT WILL HELP.

I will try it tomorrow because my problem number one is connecting application to SQL server using IP and username and password:
topic: http://www.developersdex.com/vb/mess...4053663&p=1121
----------------------------
Dobry wieczór Cor :)

Uzytkownik "Cor Ligthert" <no************@planet.nl> napisal w wiadomosci news:%2******************@TK2MSFTNGP14.phx.gbl...
Chreo,

This is a link to a page from Scorpion.
Who I saw the last days again in this newsgroups.

http://www.kjmsolutions.com/datasetarray.htm

I hope this helps

Dobry Wieczór

Cor
Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.