Micro Focus QTP (UFT) Forums
Comparing two excel files - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Comparing two excel files (/Thread-Comparing-two-excel-files)



Comparing two excel files - Sathiya - 09-26-2011

Hi guys...
i want to comapre two excel files.
the requirements for that are as follows.
1. First get the sheet count in both files if the count is not equal then exit and print the result.
2. copare the row count and column count
3. have to comapre the fonts,cell color,image etc.
4. have to compare the data in the files(row wise)
Note # wherever it fails then immediately it should show the error output and exit from run.

i have seperate code to get the count of sheets, and comparison of cell by cell that too for comparing excels having single sheet....
any one know how to do this?
please let me know....
thanks in advance



RE: Comparing two excel files - rajpes - 09-26-2011

1,2,4 are very easy.I give you code for color comparison

Code:
Set ex=createobject("excel.application")
Set wb1=ex.workbooks.open("E:\Testing\Framework\Data\a.xls")
Set wb2=ex.workbooks.open("E:\Testing\Framework\Data\b.xls")

Set sh1=wb1.activesheet
Set sh2=wb2.activesheet

colorSame=true

For each c in sh1.usedrange
color1=c.font.color
color2=sh2.range(c.address).font.color

    If clng(color1)<>clng(color2)Then
        colorSame=false
    End If

Next


ex.quit

Set sh1=nothing
Set sh2=nothing

Set wb1=nothing
Set wb2=nothing

Set ex=nothing