Skip to main content

Content Starts Here

Quickly Compare Excel Files

Article

The code below shows how to compare two Excel files. The comparison logic is implemented in the ExcelCompare script extension, which you can download by the link below. The script extension provides you with a quick way to compare the entire Excel files. If you need to compare only specified Excel sheets, go through this How To article.

After the comparison is finished, you’ll see a message containing the comparison results in the test log. If there are any differences between the files, in the test log, you’ll see the number of mismatches and the path to the results file. Otherwise, the message in the test log will indicate no mismatches.

VBScript

Sub Main
  xlfile1 = "<Path_To_the_1st_File>"
  xlfile2 = "<Path_To_the_2nd_File>"
  resfile = "<Path_To_the_Result_File>"
  Log.Message objectExcel.ExcelCompare(xlfile1, xlfile2, resfile)
End Sub

JScript

function Main() {
  xlfile1 = "<Path_To_the_1st_File>";
  xlfile2 = "<Path_To_the_2nd_File>";
  resfile = "<Path_To_the_Result_File>";
  Log.Message(objectExcel.ExcelCompare(xlfile1, xlfile2, resfile));
}

Python

def Main():
  xlfile1 = "<Path_To_the_1st_File>"
  xlfile2 = "<Path_To_the_1st_File>"
  resfile = "<Path_To_the_1st_File>"
  Log.Message(objectExcel.ExcelCompare(xlfile1, xlfile2, resfile))
Previous MonthNext Month
SunMonTueWedThuFriSat