Not able to call method to write data in excel sheet

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Not able to call method to write data in excel sheet

Anshita Sen
 I have two file  1.  where im writing my methods and another is where im calling the method. I have written the code to write data in excel but im not able to call the method in car file and write the data

public class Utils {

public static Workbook wb;
public static Sheet sh;
public static Row rw;
public static Cell cl;

public List<String> getExcelFile(String path, String sheetName, int TestCase, String sheetName1) throws Exception {

List<String> records = new ArrayList<String>();
String str = null;
FileInputStream ExcelFile = new FileInputStream(path);
wb = new HSSFWorkbook(ExcelFile);
sh = wb.getSheet(sheetName);

for (int i = 0; i < 16; i++) {

if (sh.getRow(TestCase).getCell(i).getCellType() != 1) {

str = sh.getRow(TestCase).getCell(i).getStringCellValue();

System.out.println("Data Values present in Excelsheet: " + records);
return records;

// System.out.println("Data Values present in Excelsheet: " + records);


public static List<String> setCellData(String path, String sheetName1, String ManfacturingYear, String Make,
String Model, String Variant, String Newcar, String Regyear, String Regcity, String UAEDriveExp, int RowNum,
int ColNum) throws Exception {

try {
FileInputStream writeExcel = new FileInputStream(path);

HSSFWorkbook wb = new HSSFWorkbook(writeExcel);
HSSFSheet sh1 = wb.getSheetAt(0);

int Rownum = sh.getLastRowNum();
// int colmun = -1;

for (ColNum = 0; ColNum < Rownum; ColNum++)


FileOutputStream fileout = new FileOutputStream(path);

System.out.println("Writing on Excel file Finished ...");

catch (Exception e) {
throw (e);
return null;




public class Car {
//public WebDriver driver;
CarInsurers carInsurer = new CarInsurers();
Utils utils = new Utils();
List<String> ExcelData = new ArrayList<String>();
@Test(priority = 1)
public void TestCase001() throws Exception {
ExcelData = utils.getExcelFile("Test.xls", "Sheet1", 1, null);
String TestData = String.join(",", ExcelData);
String manfYear = TestData.split(",")[0];
String make = TestData.split(",")[1];
String model = TestData.split(",")[2];
String variant = TestData.split(",")[3];
String carNew = TestData.split(",")[4];
String regYear = TestData.split(",")[5];
String regCity = TestData.split(",")[6];
String uaeDrvExp = TestData.split(",")[7];
String intDrvExp = TestData.split(",")[8];
String lastYrClaim = TestData.split(",")[9];
String claimCert = TestData.split(",")[10];
String nationality = TestData.split(",")[11];
String name = TestData.split(",")[12];
String email = TestData.split(",")[13];
String mobile = TestData.split(",")[14];
String dob = TestData.split(",")[15];
System.setProperty("", "chromedriver.exe");
WebDriver driver = new ChromeDriver();
carInsurer.selectPreQuotes(driver, manfYear, make, model, variant, carNew, regYear, regCity, uaeDrvExp, intDrvExp, lastYrClaim, claimCert, nationality, name, email, mobile, dob);

You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit
For more options, visit