how to paste datagrid data into excel sheet

  • Thread starter Thread starter TM
  • Start date Start date
T

TM

I have an Excel sheet where I setup my needed formatting, page settings,
ect, and would like to take my data from a datagrid and paste it into the
excel file and print the excel file.

Any idea how to do this ?

But. my other problem is my excel sheet if setup for two columns of
formatting, and I would like to paste the data into column 1 until it gets
to cell 30, then if there is more than 30 records, paste them into the
second column starting at the first cell.

Kind of hard to explain. But is there any way that I can do this ?
 
Hi TM,

You can read the Excel sheet using Oledbd in a dataset.
Here I have 2 rough samples, (never tested)

sample connection string "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=xxxxxx;Extended Properties=""Excel 8.0;HDR=No"""
sample select string "Select * from [sheet1$]"


To get the Excel file from the dataset, is the most easy way is to write
the underlaying dataset from the datagrid as an XML file

\\\
dataset.writeXML("xmlfileTodisk")
///

And read that into your Excel spreadsheet.

I hope this helps a little bit?

Cor
 
Oh sorry, I may have not explained properly.

My data is in an access database, read into a datagrid. I would like to
paste that into the excel file.

--
Tony



Cor said:
Hi TM,

You can read the Excel sheet using Oledbd in a dataset.
Here I have 2 rough samples, (never tested)

sample connection string "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=xxxxxx;Extended Properties=""Excel 8.0;HDR=No"""
sample select string "Select * from [sheet1$]"


To get the Excel file from the dataset, is the most easy way is to write
the underlaying dataset from the datagrid as an XML file

\\\
dataset.writeXML("xmlfileTodisk")
///

And read that into your Excel spreadsheet.

I hope this helps a little bit?

Cor

I have an Excel sheet where I setup my needed formatting, page settings,
ect, and would like to take my data from a datagrid and paste it into the
excel file and print the excel file.

Any idea how to do this ?

But. my other problem is my excel sheet if setup for two columns of
formatting, and I would like to paste the data into column 1 until it gets
to cell 30, then if there is more than 30 records, paste them into the
second column starting at the first cell.

Kind of hard to explain. But is there any way that I can do this ?
 
Back
Top