private void menuItem2_Click(object sender, System.EventArgs e)
{
this.openFileDialog1.FileName = "*.xls";
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
Excel.Workbook theWorkbook =
ExcelObj.Workbooks.Open(
openFileDialog1.FileName, 0, true, 5,
"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,
0, true);
// get the collection of sheets in the workbook
Excel.Sheets sheets = theWorkbook.Worksheets;
// get the first and only worksheet from the collection
// of worksheets
Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
for (int i = 1; i <= 10; i++)
{
Excel.Range range = worksheet.get_Range("A"+i.ToString (), "J"+i.ToString () );
System.Array myvalues = (System.Array)range.Cells.Value;
string[] strArray = ConvertToStringArray(myvalues);
listView1.Items.Add(new ListViewItem(strArray));
//
}
ExcelObj.Quit ();
}
}
the above is the code for opening an excel file and put all the elements to list box which has 10 categories...........see snapshot
now when I retrieve the list items as
MessageBox.Show(listView1.items[0].Text);
it works fine
my question is
it would NOT let me retrieve the value which is in the second or third category of listbox
like 2, 3 or 4 through items[index] thingy...........
please help
also suggest the best method for retreiving excel data into c# arrays
tahnksssssssssss