Compare Cells in the Same Row and high light mismatched cell with colour

Hi Team ,

Can you pls help me how to achieve  Comparing rows values of 2 columns  and highlight Mismatched one in  Column2  as shown in attached Screenshot.


MisMatch_1.png


3 Replies

KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team October 4, 2022 11:49 AM UTC

Hi Hruday,


Greetings from Syncfusion.


We have prepared a sample for your requirement and this can be downloaded from below link.

Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/F177944_UWP-1936431908.zip


Kindly try and let us know if this helps.


Regards,

Keerthi.



HR Hruday October 4, 2022 03:03 PM UTC

Hi Keerthi ,

Thanks for the sample ..its working but its highlights for blank cell also ..


Keerthi is their any formula based for the columns validation like how in Excel we handle ?

=IF(EXACT(A2,B2)

 




MC Mohan Chandran Syncfusion Team October 5, 2022 02:35 PM UTC

Hi Hruday,


Please find the details below.


Query

Details

How to avoid blank cells?

To skip blank cells, we suggest you check whether the cell is blank before applying the color to that cell.

 

Please refer to the below code snippet.

 

for (int row = 2; row <= usedRange.LastRow; row++)

{

    if(worksheet.UsedRange[row, 1].Value != worksheet.UsedRange[row, 2].Value && !worksheet.UsedRange[row, 2].IsBlank)

    {

        worksheet.UsedRange[row, 2].CellStyle.ColorIndex = ExcelKnownColors.Red;

    }

}

Excel-like formula validation for columns

We suggest you to use the data validation in XlsIO to restrict the cell values in the Excel columns.

 

https://help.syncfusion.com/file-formats/xlsio/working-with-data-validation#custom-validation

 

If it does not achieve your requirement, please provide your requirement in more detail. It will help us to check further and provide you with a solution at the earliest.



Regards,

Mohan.


Loader.
Up arrow icon