I’m having some troubles while reading from an exel in c#.
I have this code which i read every cell from A to X.
int i = 1;
int number;
System.Array myvalues; string[] strArray;
Microsoft.Office.Interop.Excel.Range range = worksheet.get_Range("A" + i.ToString(), "X" + i.ToString());
while(range.Count!=0)
{
i++;
range = worksheet.get_Range("A" + i.ToString(), "X" + i.ToString());
myvalues = (System.Array)range.Cells.Value;
strArray = ConvertToStringArray(myvalues);
number = Convert.ToInt32(strArray[0]);
}
My question is: How could i read next 4 * “number” rows in excel based on “number” value ?
For example:
A B C D E F G H I J
a a a a a 1 a a a a
F’s cell value is 1 so i would like to read ( G H I J)
If F’s cell value is 2 the i would like to read ( G H I J K L M N)
A B C D E F G H I J K L M N
a a a a a 2 a a a a a a a a
F’s cell value 3 :
A B C D E F G H I J K L M N O P Q R
a a a a a 3 a a a a a a a a a a a a
code:
method for read range:
EDIT
Reads the value of the column “F”, multiplicas the value by 4 and add the amount of previous columns (up to “F”). You then use this (this unproven) function to get the letter.
EDIT II