Java – Fillo Implementation

authenticationimport-from-exceljava

I came across a really nice and simple xls and xlsx implementation API called Fillo. I've made a spread sheet with the following values as most people know the all caps sections are for category names to seac

USERID    PASS
joe       bigjoe
jim       bigjim
john      bigjohn

Now here's the code:

    import Exception.FilloException;
    import Fillo.*;


  public class CallBack {
    public static void main(String args[]) throws FilloException {
        testFillo();
    }

    private static void testFillo() throws FilloException {
        Fillo fillo=new Fillo();
        Connection connection=fillo.getConnection("logindatabase.xls");
        String strQuery="Select * from Sheet1 where USERID='*' and PASS='*'";
        Recordset recordset=connection.executeQuery(strQuery);

        /*
         * I'm wanting the login check to be right here
         */

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

    }
}

The login function should go through the USERID column first and once it finds that it will check the corresponding PASS value. So if it found "jim" as the user it then check for "bigjim" as the password.

So the big question would be: How would I set something like this up?

Here's the Fillo Documentation.

All the best,

Groax

Best Answer

you can try this... It's not completely customized but it will help...

public static void selectData(String tcid,String fieldName) throws FilloException{

    Fillo fillo=new Fillo();
    Connection connection=fillo.getConnection("testdata//testcasedata.xlsx");
    String strQuery="Select * from data where TCID='"+tcid+"'";
    Recordset recordset=connection.executeQuery(strQuery);
    while(recordset.next()){
        ArrayList<String> dataColl=recordset.getFieldNames();
        //System.out.println(dataColl);
        Iterator<String> dataIterator=dataColl.iterator();
        //System.out.println(dataColl.size());  

        while(dataIterator.hasNext()){
            for (int i=0;i<=dataColl.size()-1;i++){
                //System.out.println(i);
                String data=dataIterator.next();
                String dataVal=recordset.getField(data);

                if (dataVal.equalsIgnoreCase(fieldName)){
                    //System.out.println("passed");
                    i=i+1;
                    //System.out.println(i);
                    String testData=dataColl.get(i);
                    System.out.println(recordset.getField(testData));   

                }

            }

            break;
        }
    }

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

}
Related Topic