Wednesday 6 February 2019

Read Excel Input Files In yours selenium projects using a new way, FILLO API.

FILLO API: FILLO SELENIUM:

Fillo is an Excel API for Java and you can query xls & xlsx files. It supports DDL , DML AND DCL commands over SQL.


==============================================================


1.FILLO SELECT

SELECT SQL:
===========

Syntax:
SELECT column1, column2, columnN FROM table_name;



USING SELECT:
=============
public class Filo_Select {
public static void main(String[] args) throws InterruptedException {

 Fillo fillo=new Fillo();
 Connection connection=fillo.getConnection("C:\\VikasTest\\TestingExcel.xlsx");
 String strQuery="Select * from Sheet1 where name='Vikas'";
 Recordset recordset=connection.executeQuery(strQuery);

  while(recordset.next()){
  System.out.println(recordset.getField("Details"));
 }

  recordset.close();
 connection.close();
}

}

2.FILLO UPDATE:
================

Fillo is an Excel API for Java and you can query xls & xlsx files

It supports DDL,DML AND DCL COMMANDS


public class Filo_Update
{
public static void main(String[] args) throws InterruptedException
{

 Fillo fillo=new Fillo();
 Connection connection=fillo.getConnection("C:\\VikasTest\\TestingExcel.xlsx");
 String strQuery="Update Sheet1 Set Course='selenium' where name='Vikas'";

 connection.executeUpdate(strQuery);

 connection.close();
}
}


3.INSERT FILLO:
=================

INSERT IN SQL:
=============
SYNTAX:
========
INSERT INTO TABLE_NAME (column1, column2, column3,...columnN)]
VALUES (value1, value2, value3,...valueN);

Here, column1, column2,...columnN are the names of the columns in the table into which you want to insert data.


//EXAMPLE INSERT COMMAND

public class Filo_Update
{
public static void main(String[] args) throws InterruptedException
{

 Fillo fillo=new Fillo();
 Connection connection=fillo.getConnection("C:\\VIKAS\\TestingExcel.xlsx");
 String strQuery="INSERT INTO Sheet1(Name,Course) VALUES('VIKAS','SELENIUM WITH JAVA')";

 connection.executeUpdate(strQuery);

 connection.close();
}
}


4.FILLO::MULTIPLE WHERE CONDITION IN FILLO:
===============================================
FILLO::MULTIPLE WHERE CONDITION IN FILLO:
========================================
Syntax:
=====
Recordset recordset=connection.executeQuery("Select * from Sheet1 where column1=value1 and column2=value2 and column3=value3 and column4=value4");


//Example

public class Filo_Update
{
public static void main(String[] args) throws InterruptedException
{

 Fillo fillo=new Fillo();
 Connection connection=fillo.getConnection("C:\\Vikas\\TestingExcel.xlsx");
 String strQuery="INSERT INTO Sheet1(Name,Course) VALUES('Vikas','SELENIUM WITH JAVA')";

 //with multiple where conditions
 Recordset recordset=connection.executeQuery("Select * from Sheet1 where column1=value1 and column2=value2 and column3=value3");

 Recordset recordset=connection.executeQuery("Select * from Sheet1 where Name=Vikas and Course=SELENIUM WITH JAVA and ID=3");

 connection.close();


5.FILLO:WHERE METHOD:
======================
FILLO:WHERE METHOD:
=====================

Syntax:
======
Recordset recordset=connection.executeQuery("Select * from Sheet1").where("COLUMN=VALUE").where("COLUMN=VALUE'");


//Example on where method in fillo

public class Filo_Where
{
public static void main(String[] args) throws InterruptedException
{



 Fillo fillo=new Fillo();
 Connection connection=fillo.getConnection("C:\\VikasTest\\TestingExcel.xlsx");


 //with  where method
 Recordset recordset=connection.executeQuery("Select * from Sheet1").where("Name=Ramesh").where("Course='Selenium'");

 connection.close();
}
}




6.FILLO Set table starting row and column:
==========================

Syntax:
========

//Table start row
System.setProperty("ROW", "rownumber");

////Table start column
System.setProperty("COLUMN", "columnnumber");


//Example on Set table starting row and column

public class StTableDemo {
 public static void main(String[] args) throws InterruptedException {

  // Now set table start row and column

  // Table start row
  System.setProperty("ROW", "1");

  // Table start column
  System.setProperty("COLUMN", "4");

  Fillo fillo = new Fillo();
  Connection connection = fillo.getConnection("C:\\VikasTest\\TestingExcel.xlsx");

  // with where method
  Recordset recordset = connection.executeQuery("Select * from Sheet1")
    .where("Name=Vikas").where("Course='Selenium'");

  connection.close();

 }
}

No comments:

Post a Comment