Export datagrid contents to EXCEL

  • Thread starter Thread starter chreo
  • Start date Start date
C

chreo

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?
 
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
 
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
 
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")
 
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/message.asp?r=4053663&p=1121
----------------------------
Dobry wieczór Cor :)

Uzytkownik "Cor Ligthert" <[email protected]> napisal w wiadomosci 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top