Store variable in Excel not working

Hi Community,

I got the following issue where I create a variable in my testcase which does store data (I can verify that in my console). But for some reason it does not want to store the data into Excel.
When using this method, but instead of the variagble, I use an object which has data stored by means of getText. Then it does work.
For some reason it looks like Katalon doesn’t want to store the data when it’s a viarable.
Perhaps I am doing something wrong?

Here is my code;

//Store todaysDate in Excel.
Date today = new Date()
String todaysDate = today.format(‘dd-MM-yyyy HH:mm’)
String excelFilePath = ‘D:\\Data.Template.xlsx’
String sheetName = ‘Basis’
String textToWrite = todaysDate

workbook01 = ExcelKeywords.getWorkbook(excelFilePath)
sheet01 = ExcelKeywords.getExcelSheet(workbook01, sheetName)

for (int rowIndex = 1; rowIndex < 2; rowIndex++) {
ExcelKeywords.setValueToCellByIndex(sheet01, rowIndex, 3, textToWrite)

The script passes and says it successful.
And in the console I can see the actual date + hh:mm format with the println(todaysDate).
I get no error. The only thing I can see is that the date is not stored into my excel file.

Does anyone have an idea what goes wrong here?

Hi @paulo.resende

I think you have to save the workbook by calling ExcelKeywrd.saveWorkbook in order for the changes to be persisted

Hi @ThanhTo,

Thanks for the reply.

I finally saw what you ment. Seems I indeed forgot that line at the end of my script. Thanks man!
Not sure how I didn’;t saw it myself.

1 Like