Your
ReadCell
method is incorrect, you have the following:
public string ReadCell(int i, int j)
{
for ( i = 0; i < 26; i++)
{
for ( j = 1; j < 100; j++)
{
int first = 65 + i;
string coordinates = ((char)first).ToString() + j;
if (ws.Range[coordinates].Value == "Z_KomSilnice_L (24200)/7 ")
{
return ws.Range[coordinates].Value;
}
else
return "";
}
}
}
First, you are missing a return at the end for the case when both loops complete without finding the string you want.
Second, you are ignoring the values passed in which denote the cell to test.
And third, your first range value in the loop will be "A1", but if that does not contain the search string then the method will return the blank string, and not test any further.
You should change your code to:
public string ReadCell(int i, int j)
{
for ( i = 0; i < 26; i++)
{
for ( j = 1; j < 100; j++)
{
int first = 65 + i;
string coordinates = ((char)first).ToString() + j;
if (ws.Range[coordinates].Value == "Z_KomSilnice_L (24200)/7 ")
{
return ws.Range[coordinates].Value;
}
}
}
return "";
}
However, that is a very wasteful piece of code. You should use the values of i and j that are passed in to select the cell to test.
I am still at a loss to understand why the code that I tested successfully does not work on your system.