AnsweredAssumed Answered

Importing External Jar

Question asked by sriram.mk3 on Dec 8, 2016
Latest reply on May 7, 2018 by kirancts

Hi, 

      I have coded a program to update the datasheet with required values after performing few steps. This program has a function/method that get 3 arguments and perform the excel update action. I have written this code in java and added required dependencies and tested and exported it to .jar. I placed the .jar file in hotDeploy and lib folders of DevTest and tried to access the same in devtest. But am not able to access the method from the .jar. Kindly help me in resolving the issue. Whether we need to extend some inbuilt class of Devtest or what needs to be done to invoke the method from external .JAR.

 

Sample Code: UpdateDataSheet.java

package com.automation.ExcelUpdate;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;


import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class UpdatedDataSheet
{
public void updatesheet(String filename,String sheetname,int RowNumber) throws Exception
{
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(filename));
XSSFSheet worksheet = workbook.getSheet(sheetname);
Cell cell = null;
cell = worksheet.getRow(RowNumber).getCell(0);
cell.setCellValue("N");
FileOutputStream output_file =new FileOutputStream(new File(filename));
workbook.write(output_file);
workbook.close();
output_file.close();
}
}

 

In Devtest: Scripted Assertion

import com.automation.ExcelUpdate

updatesheet(filename,sheetname,rownumber)

 

Thanks!!!

SRIRAM MK

Outcomes