SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 9 of 9
  1. #1
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to comparing Two Excel sheets

    Hi

    Is there a way to quickly compare two excel sheets? For example, I have a excel sheet that is 10 columns wide by 200 rows. I want to compare that to another table(in Excel), has anyone done this, is there a (relatively) simple way of doing this? Please anyone help me.

    ThankYou
    Sai

  2. #2
    Junior Member
    Join Date
    Oct 2005
    Location
    Mumbai
    Posts
    24
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to comparing Two Excel sheets

    Hi Sai,

    Below script compares two excel files file1,file2.

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f1 = fso.OpenTextFile("C:\file1.xls", 1)
    Set f2 = fso.OpenTextFile("C:\file2.xls", 1)

    if f1.readall=f2.readall then
    msgbox "Files are equal"
    else
    msgbox "Files are not equal"
    end if


    Thanks&Regards
    krishna chaitanya.k

  3. #3
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to comparing Two Excel sheets

    Hi Krishna,

    I used above code it's not working. Even same excel sheet(Coulmns,Rows) also same. It's always say Files are not equal.

    This is code

    Set fso=CreateObject("Scripting.FileSystemObject")
    Set f1=fso.OpenTextFile("C:\Book1.xls",1)
    Set f2=fso.OpenTextFile("C:\Book2.xls",1)

    If f1.readall=f2.readall Then
    msgBox "Files are equal"
    Else
    msgBox "Files are not equal"
    End If

  4. #4
    Senior Member
    Join Date
    Jan 2000
    Location
    USA, CA
    Posts
    1,998
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to comparing Two Excel sheets

    There is function: CompareSheets(sourceFile,sPath,destFile,dPath,sShe et,dSheet,sFirstRow,sFirstColumn, sLastRow,sLastColumn)
    from Nadim.
    Or here in this forum or in MI customer section.
    Search it, please.
    Or ask personally Chillyhouse52556 -
    (QA forum's member#87342)

    Janna

  5. #5
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: How to comparing Two Excel sheets

    Krishna, your function is never gonna work on this earth....it's a function to compare to simple text file and not some office file. When you save files from a special program say microsoft word, excel etc.... then it's save in some specific format which properitary to the tool and it is never a simple text file in many cases. There are 100s of things stored in that like author name, some machine info, office etc... so even if you try to create to same files you wont be able to get the same raw file easily but yes the output of both the files may be same.

  6. #6
    Senior Member
    Join Date
    Jan 2000
    Location
    USA, CA
    Posts
    1,998
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to comparing Two Excel sheets

    We are wonderful team, guys!
    Happy to be with you.

    Janna

  7. #7
    Senior Member
    Join Date
    Jun 2004
    Location
    Miami,FL
    Posts
    949
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to comparing Two Excel sheets

    Janna you are right.I did it with the help of MoTest and your self.I remeber you told me hoe to set the cell background color
    Here it is
    http://www.qaforums.com/cgi-bin/foru...;f=20;t=003246

    HTH

    [ 02-13-2006, 12:20 PM: Message edited by: chillyhouse52556 ]
    "I realize it's an error, but no one is going to try to do that!"
    From "Top 10 Stupid Comments from Developers".

  8. #8
    Junior Member
    Join Date
    Jan 2006
    Location
    Manila, Philippines
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to comparing Two Excel sheets

    i tried using Krishna's code and found it to be working...

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f1 = fso.OpenTextFile("C:\file1.xls", 1)
    Set f2 = fso.OpenTextFile("C:\file2.xls", 1)

    if f1.readall=f2.readall then
    msgbox "Files are equal"
    else
    msgbox "Files are not equal"
    end if


    I even tried .doc, .xls and made some changes in the file to check whether the code validates any differences and it does. I also tried it with .rpt and it was still able to validate it.

    Hmmm.. does it have anything to do with other codes you attach it to?

  9. #9
    Junior Member
    Join Date
    Jan 2006
    Location
    Manila, Philippines
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to comparing Two Excel sheets

    Just to add another question...

    Is it possible to parameterize the files to be checked?

    Let's say for example below:

    Set f1 = fso.OpenTextFile("C:\file1.xls", 1)
    Set f2 = fso.OpenTextFile("C:\file2.xls", 1)

    How do I instruct QTP to check a new set of files after validating file1.xls and file2.xls so that i dont have to change the code everytime new files are generated?

    Is it possible for me to place the filenames in the data table?

    Thanks Guys! [img]images/icons/grin.gif[/img]

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 9.38%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 10:20 AM.

Copyright BetaSoft Inc.