View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
[email protected] crferguson@gmail.com is offline
external usenet poster
 
Posts: 91
Default Block copy of Datatable to Excel Spreadsheet using C#

However, in spite of misreading your question, I don't think the
content of the link posted addresses it either. Perhaps if you can
get the contents of the datatable into an array (or it might work
straight from the datatable if the Excel object recognizes it as an
array), you can simply set the Excel Range equal to your array. Kind
of the reverse of what I posted in the first place. You just have to
specify the range specifically. For example if your datatable has 5
columns and however many rows:


MyWorkbook.Range("A1:E" & ubound(YourZeroBasedArray)+1) =
YourZeroBasedArray


On Oct 30, 8:48 am, "
wrote:
I'm not sure exactly what the code would be in C#, but all you need is
to get the excel workbook object and then set an array equal to the
range of cells you're wanting to pull. Assuming you already have the
workbook object (let's say MyWorkbook) since you're already pulling
cell by cell:

Dim arrRange
arrRange = MyWorkbook.Range("A1:C10")

On Oct 30, 8:33 am, Peter S. wrote:



I am currently copying data from a DataTable to an Excel spreadsheet on a
cell by cell basis. I would like to speed things up by doing this on a row by
row basis or one big block copy. I can't seem to be able to figure out on how
to do this on a row by row basis or by one single command. Can anyone supply
a snippet of how this can be performed? Thanks!- Hide quoted text -


- Show quoted text -