I am working with excel in importing records to the program I am currently creating. I usually get records from excel and store it to array through column index as follows:
Excel.Range xlRange = xlWorksheet.UsedRange;
string[,] arr = new string[rowCount, colCount];
for (int i = 1; i <= rowCount; i++)
{
for (int j = 1; j <= colCount; j++)
{
arr[i, j] = xlRange.Cells[i, j].Value;
}
}
Now, in the work I am currently doing, column index is unknown. The only given is the column Name such as column "AP", "QR", etc. The user will be the one to define what column will he get the data from.
Is there any way like arr[i, j] = xlRange.Cells["AP", j].Value;
?
NOTE:
The array will contain data from two or more columns, not just one.