Praveen Kumar
Posts: 23
Joined: 2008-02-02
|
I have a use case, where the users will select the columns they need from an Excel sheet. I need to prepare data by looping through all the used rows in the excel sheet and creating a dataset (list of objects) for only those columns selected.
My question is:
What is the best way to loop through all used rows and read cell data from columns by their name?
ThanksBest Regards,
Praveen |
|
Andrei Smolin
Add-in Express team
Posts: 18664
Joined: 2006-05-11
|
Hello Praveen,
The best way to read and write multiple cell is to to construct an Excel.Range object pointing to these cells and get or set Range.Value (or Range.Value2). If the Range object points to a single cell, this property accepts and returns a single value. If the Range object represents multiple cells, this property returns an array.
If you select a complete column(s), the resulting array may be too large. To minimize it, construct your Range as an intersection of the selection and Used Range. If the resulting range is still too large, you can construct a series of Ranges each covering only part of the whole Range.
Regards from Poland (CEST),
Andrei Smolin
Add-in Express Team Leader |
|
Praveen Kumar
Posts: 23
Joined: 2008-02-02
|
Thank you for your quick reply.Best Regards,
Praveen |
|