G
Gani tpt
Guest
I am comparing two work sheets and finding mismatching cell in the difference.
My both excel sheets are reading properly. but, while checking the cell in both sheets, it always shows "0" zero values.
Each sheet range starts from A10 to IJ10)
column starts range A to IJ Column in both sheets
Row Starts range 10th row in both sheets.
what is the problem in my source code.?
string strRangeToCheck;
strRangeToCheck = "A10:IV10";
lastLine = Math.Max(
XLWS1.Range[strRangeToCheck].Rows.Count,
XLWS2.Range[strRangeToCheck].Rows.Count);
for (int row = 1; row <= lastLine; row++)
{
// maximum column
int lastCol = Math.Max(
XLWS1.Range[strRangeToCheck].Columns.Count,
XLWS2.Range[strRangeToCheck].Columns.Count);
for (int column = 1; column <= lastCol; column++)
{
double? Currval = new double?();
double? Prevval = new double?();
//int? value = new double?();
Currval = Convert.ToDouble(XLWS1.Cells[row, column].Value);
Prevval = Convert.ToDouble(XLWS2.Cells[row, column].Value);
// Check for if the object is null.
if ((Currval == null) || (Prevval == null))
{
// Your code goes here.
}
else
{
if (Currval != Prevval)
{
((Excel.Range)XLWS1.Cells[row, column]).Interior.Color = 255;
((Excel.Range)XLWS2.Cells[row, column]).Interior.Color = 5296274;
}
}
}
}
Some where i did mistake to read Rows and columns...where is that...?
Continue reading...
My both excel sheets are reading properly. but, while checking the cell in both sheets, it always shows "0" zero values.
Each sheet range starts from A10 to IJ10)
column starts range A to IJ Column in both sheets
Row Starts range 10th row in both sheets.
what is the problem in my source code.?
string strRangeToCheck;
strRangeToCheck = "A10:IV10";
lastLine = Math.Max(
XLWS1.Range[strRangeToCheck].Rows.Count,
XLWS2.Range[strRangeToCheck].Rows.Count);
for (int row = 1; row <= lastLine; row++)
{
// maximum column
int lastCol = Math.Max(
XLWS1.Range[strRangeToCheck].Columns.Count,
XLWS2.Range[strRangeToCheck].Columns.Count);
for (int column = 1; column <= lastCol; column++)
{
double? Currval = new double?();
double? Prevval = new double?();
//int? value = new double?();
Currval = Convert.ToDouble(XLWS1.Cells[row, column].Value);
Prevval = Convert.ToDouble(XLWS2.Cells[row, column].Value);
// Check for if the object is null.
if ((Currval == null) || (Prevval == null))
{
// Your code goes here.
}
else
{
if (Currval != Prevval)
{
((Excel.Range)XLWS1.Cells[row, column]).Interior.Color = 255;
((Excel.Range)XLWS2.Cells[row, column]).Interior.Color = 5296274;
}
}
}
}
Some where i did mistake to read Rows and columns...where is that...?
Continue reading...