While testing any reporting application, one comes under situations when he/she have to compare two excel files. If the excel sheets are small, its easier to compare them manually but as long the sheets becomes large, you need some automated way to compare those.
Earlier, i used to export those files as csv and then comparing them using perl scripts but it was an overhead to exporting and then comparing so i thought of doing something within the excel sheets itself. After googling, i found that it can be done by using Excel Macros. I did try that, but found that you need to open those excel files in Microsoft Excel and then apply the macro, which again i didn't like as it require to open MS Excel. I was interested to have a program which i can run from command prompt. Finally i got my solution. I converted the above macro as a standalone vb script program and used it from command prompt.
The great benefit with this script is that i can take control of displaying the diff results (currently, i am highlighting the rows in the excel sheet itself.)
to run this program, open command prompt and run following command:
C:\> cscript /nologo ExcelCompare.vbs <ExcelFile1> <ExcelFile2>
Following is the program:
Sunday, May 17, 2009
Comparing Excel Files
Posted by
Vishnu Agrawal
at
11:44 PM
0
comments
Run a Visual Basic Script Program from a command prompt
A Visual Basic script program can be run from a DOS prompt. cscript command can be used for this purpose.
C:\>cscript <pathToVBScriptFile>
by default cscript command displays the Microsoft Header but this can be avoided by providing /nologo argument.
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
C:\>cscript /nologo <pathToVBScriptFile>
User can also take control to take input and display the output on the console. For that user had to use following options in the VB Script.
dim input
dim output
dim name
set output = wscript.stdout
set input = wscript.stdin
output.write "Enter Your Name : "
name = input.readline
Posted by
Vishnu Agrawal
at
12:04 PM
0
comments
Labels: vbscript