Excel Range to DataTable and Vice Versa?

  • Thread starter Thread starter TCook
  • Start date Start date
T

TCook

Hey All,

Using a range object, is there a quick way to blast the data into a
datatable?

For example, using a range object, one can dump the data to an array. Is
there a way to do something similar with a range object and a datatable?

Is there a quick way to dump the data from an array into a datatable?

How about doing the reverse? Can I blast a range with data from a datatable
similarly to using an array?

I won't be using connection strings, etc. I will be using range objects.

Thanks & Regards,

TC
 
Enter this into Google search: ADO.NET, Excel

You'll be overwhelmed by the liks of this topic.
 
Hey Norman,

You are correct in that I will be overwhelmed by the links but I am looking
for something very specific that is also performance related.

Can you answer the specific questions posed?

Thanks & Regards,

TC
 
To read/write data from your app's DataTable object to/from Excel sheet, you
have two options: automate Excel with COM interop, or use ADO.NET, as the
tons of links show.

Using ADO.NET (you need ConnectionString) is a lot faster, and you do not
even need Excel installed.

Using COM automation, yes, you access data in the sheet cell by cell in a
Range/sheet. You need Excel be installed, it is slow, may be too slow if you
have thousands of cells in the Range. Yes, you can get data in the Range
into an array and then sinply loop through the array to add them into a
DataTable. The point is, you need to automate Excel to access the said
Range/Cells

If you want to two-way transfer and need more control to the sheet, such as
format the cells according to the cell's value in many different ways, then
you have no choice by automation. If you only need to read/write data back
and forth, using ADO.NET with connectionString is the obvious choice.
 
Back
Top