lrbehmer
14 years agoContributor
Fun with Excel
Frankly, this is starting to look like a bug but I didn't want to jump the gun.
I'm using a spreadsheet that has input and expected outputs in their respective columns. I'm taking the results from our application and writing them to another set of columns. The logic in the test compares the actual results with the expected results that are already in the spreadsheet. If they don't match, I change the color of the cell for the value in question.
So, I have this bit of logic:
if(Excel.Cells(i, j+24) == "Null")
{
Log.Message("Accecptable Error, test passed");
}
else
{
var numOne = (aqConvert.StrToFloat(Excel.Cells(i, j+24))) ;
}
(i and j are defined beforehand. this code exists in a loop.)
Everything goes fine until I add a loop beforehand that clears the contents of the cells for the new results:
j = 2 ; // j = column
for (i = 3; i<=17; i++) // i = row
{
columnCounter = 23 ;
while(columnCounter<=26)
{
Excel.Cells(i, j+columnCounter).Interior.ColorIndex = 0 ; // Reset Cell background color to WHITE
Excel.Cells(i, j+columnCounter).ClearContents ; // Clear Cell data
columnCounter++ ;
}
}
After this new loop is added to the beginning of the script, I get an error: "An exception occurred...The argument is not a number." right at the "numOne = aqConvert.StrToFloat()" spot.
My question is - "Why am I getting this exception?"
TIA.
I'm using a spreadsheet that has input and expected outputs in their respective columns. I'm taking the results from our application and writing them to another set of columns. The logic in the test compares the actual results with the expected results that are already in the spreadsheet. If they don't match, I change the color of the cell for the value in question.
So, I have this bit of logic:
if(Excel.Cells(i, j+24) == "Null")
{
Log.Message("Accecptable Error, test passed");
}
else
{
var numOne = (aqConvert.StrToFloat(Excel.Cells(i, j+24))) ;
}
(i and j are defined beforehand. this code exists in a loop.)
Everything goes fine until I add a loop beforehand that clears the contents of the cells for the new results:
j = 2 ; // j = column
for (i = 3; i<=17; i++) // i = row
{
columnCounter = 23 ;
while(columnCounter<=26)
{
Excel.Cells(i, j+columnCounter).Interior.ColorIndex = 0 ; // Reset Cell background color to WHITE
Excel.Cells(i, j+columnCounter).ClearContents ; // Clear Cell data
columnCounter++ ;
}
}
After this new loop is added to the beginning of the script, I get an error: "An exception occurred...The argument is not a number." right at the "numOne = aqConvert.StrToFloat()" spot.
My question is - "Why am I getting this exception?"
TIA.