An ability to write out data values from fields to an excel file when executing a script

An ability to write out data variables to Excel. E.g. I am testing a retail application and each time I create an order, the system generates an order number that I would like to capture and write out to an Excel file.

Ideally I would like to write to the same Excel file I have used as my data input

4 Likes

I really wonder a solution for that

I’ll second this Iain my old mate I could do with this, it would be an excellent addition to a great product

Hi,

You can create custom keyword for this which will read data from screen and write the output to the excel file.

May be you can try this:-

package writeDataToExcel

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint

import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase

import static com.kms.katalon.core.testdata.TestDataFactory.findTestData

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.annotation.Keyword

import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint

import com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactory

import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords

import com.kms.katalon.core.model.FailureHandling

import com.kms.katalon.core.testcase.TestCase

import com.kms.katalon.core.testcase.TestCaseFactory

import com.kms.katalon.core.testdata.TestData

import com.kms.katalon.core.testdata.TestDataFactory

import com.kms.katalon.core.testobject.ObjectRepository

import com.kms.katalon.core.testobject.TestObject

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords

import internal.GlobalVariable

import MobileBuiltInKeywords as Mobile

import WSBuiltInKeywords as WS

import WebUiBuiltInKeywords as WebUI

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import org.apache.poi.hssf.usermodel.HSSFSheet;

import org.apache.poi.ss.usermodel.Row;

import org.apache.poi.ss.usermodel.Sheet;

import org.apache.poi.ss.usermodel.Workbook;

public class WriteDataToExcelSheet

{

@Keyword

def WriteDatatoDataFile(String username, Integer rownum)

{

String xlsPath = (“C:\\XXX\\KatalonStudio_XXX\\XXX\\Data Files\\XXX_Dataset.xls”);

File f1=new File(xlsPath);

FileInputStream fIPS= new FileInputStream(xlsPath); //Read the spreadsheet that needs to be updated

HSSFWorkbook wb = new HSSFWorkbook(fIPS);

HSSFSheet ws = wb.getSheetAt(0);

ws.getRow(rownum).createCell(3).setCellValue(username)

FileOutputStream fout=new FileOutputStream(f1);

wb.write(fout);

fIPS.close();

}

}

I implemented using Apache POI

https://poi.apache.org/

This type of request is going trendy, and the following feature may suits your needs. If you think it does, you may upvote it for Katalon guys to add it in a further release :

1 Like