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

how to paste datagrid data into excel sheet

P: n/a
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 ?
--
Tony


Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Cor
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 ?
--
Tony

Nov 20 '05 #2

P: n/a
TM
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" <no*@non.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
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 ?
--
Tony


Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.