Forum Discussion

abhi0096's avatar
abhi0096
New Contributor
9 years ago

Trying to Compare two Excel sheet to check if any diffrence and print those diffrence

Trying to compare two excel sheet using Groovy script to match my expected and actual result if there's any diffrence print that. But in Soap Ui using DATA Sink when trying to find it's not taking groovy script result 

 

import jxl.*;
import jxl.read.biff.BiffException;
import java.io.File;
import java.io.IOException;

def alert = com.eviware.soapui.support.UISupport;

//This will display an information message


Workbook rxOrderInput = Workbook.getWorkbook(new File("C:\\Users\\abhishekk\\Desktop\\IIB\\Data Source\\Test2.xls"));
Workbook rxOrderOutput = Workbook.getWorkbook(new File("C:\\Users\\abhishekk\\Desktop\\IIB\\Data Source\\Sheets\\Test1.xls"));
Sheet sheetInput = rxOrderInput.getSheet(0);
Sheet sheetOutput = rxOrderOutput.getSheet(0);

int rowCount = sheetInput.getRows();
//log.info(rowCount);
int colCount = sheetInput.getColumns();
//log.info(colCount);
for(int rowIndex =1; rowIndex<rowCount; rowIndex++)
{
for(int colIndex = 0 ;colIndex < colCount; colIndex++)
{
def contentInput = sheetInput.getCell(colIndex, rowIndex).getContents() ;
def contentOutput = sheetOutput.getCell(colIndex, rowIndex).getContents();
//log.info(sheetInput.getCell(colIndex, rowIndex).getContents());
//log.info(sheetOutput.getCell(colIndex, rowIndex).getContents());
if(contentInput != contentOutput)
{
//log.info(contentInput);
//log.info(contentOutput);
result= ("Row:"+rowIndex+" Column:"+colIndex+"\n"+contentInput + "\n"+contentOutput);
}
}
}