newbie q - create list of objects from excel worksheet

E

eddiec

Hi,

I have read an Excel worksheet into a DataSet. Now I want to create an
array of objects using the records in the DataSet.

For each record in the dataset
Create an object
Initialise the properties of the object with the values in the
record's fields
Add the object to an array
Next

What is the best way of iterating through the DataSet and reading the
fields?

cheers,

eddiec :)
 
P

Peter Duniho

Hi,

I have read an Excel worksheet into a DataSet. Now I want to create an
array of objects using the records in the DataSet.

For each record in the dataset
Create an object
Initialise the properties of the object with the values in the
record's fields
Add the object to an array
Next

What is the best way of iterating through the DataSet and reading the
fields?

If your question is actually specific to how you've imported the data from
the Excel spreadsheet into your DataSet, you should post your question in
the Office interop newsgroup where people who are more familiar with
Office interop issues can help you.

If the question isn't specific to how you've imported the data from the
Excel spreadsheet, then you should probably avoid even mentioning the
spreadsheet, rather than complicating the question unnecessarily.

As for the question itself, while I'm not familiar with this exact
scenario, it seems to me that you should have a Table in your DataSet
representing the rows of data in the spreadsheet. Extracting the data
would be no different than extracting rows from any database table. Just
enumerate the rows and copy the values into instances of a class of your
choosing, adding each instance to a collection (an array is fine,
especially if you know the number of rows in advance -- which you should
-- and can simply initialize the array to the correct size from the
outset).

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top