Retrieve data from excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i'm trying to get data out of excel...

my code is:

private void exlSelectionChanged(Range rng)
{
lstFields.Items.Clear();
for (int i=1; i<=rng.Columns.Count ; i++)
{
lstFields.Items.Add( rng.Cells[1,i]).ToString() );
}

(i'm trying to put the first row of the selection into a listbox).
what i get is a listbox full of
System.__ComObject

please help...
 
Ubi,

The Excel COM object does not implement ToString(). You are getting
System._ComObject's (The base for all COM Interop RCWs) implementation of
ToString(), which I believe just returns the type name.

You need to use the Value2 property of the Excel Cell object...

Hope this helps...

Wadih Pazos
Software Architect
Solutions@MBA
www.satmba.com
www.PaperSave.com
 
Back
Top