Topic
  • 13 replies
  • Latest Post - ‏2011-07-15T10:02:29Z by Sathish804
SystemAdmin
SystemAdmin
16727 Posts

Pinned topic How to open and read data from excel in RFT ?

‏2009-07-09T06:34:57Z |
Hi Guys,

I want to open excel-sheet in RFT.I want to use excel-sheet in place of conventional data pool and pass the data to my script from the excel only.

I will be very thankful if anybody can pass the script code in java for opening excel in RFT and for reading data from that excel.

What is simplest way to do it???

Thanks,
Manit
Updated on 2011-07-15T10:02:29Z at 2011-07-15T10:02:29Z by Sathish804
  • pabrams
    pabrams
    664 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2009-07-09T15:26:15Z  
    Wrong forum. You need a forum that deals specifically with java. Once you find one, search it for keywords such as "Excel".
  • testudo
    testudo
    29 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2009-07-15T03:05:19Z  
    To be somewhat more helpful

    Try doing a google search on jxl.jar

    Also there are some articles within IBM pertaining to this.

    Actually I would debate if this is the wrong forum, as intrinsically RFT (Java)/ Eclipse and Java are some what intertwined.
  • Sathish804
    Sathish804
    1369 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2009-07-15T04:05:52Z  
    You may try POI package of Apache for reding and writing to Excel....search for POI package in Google...
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2009-07-15T11:49:47Z  
    I guess the simplest way is to import excel contents into your datapool :)

    Save your excel file as csv, right click your datapool in RFT and select import, follow the directions.
  • pabrams
    pabrams
    664 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2009-07-15T14:43:07Z  
    • testudo
    • ‏2009-07-15T03:05:19Z
    To be somewhat more helpful

    Try doing a google search on jxl.jar

    Also there are some articles within IBM pertaining to this.

    Actually I would debate if this is the wrong forum, as intrinsically RFT (Java)/ Eclipse and Java are some what intertwined.
    >>Actually I would debate if this is the wrong forum, as intrinsically RFT (Java)/ Eclipse and Java are some what intertwined.

    No they aren't - a lot of people use VB.Net/Visual Studio.

    >> I will be very thankful if anybody can pass the script code in java for opening excel in RFT and for reading data from that excel.

    He asked for code on how to read data from excel to java. The code will be exactly the same whether he's using RFT or not.
  • pabrams
    pabrams
    664 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2009-07-15T14:44:30Z  
    • testudo
    • ‏2009-07-15T03:05:19Z
    To be somewhat more helpful

    Try doing a google search on jxl.jar

    Also there are some articles within IBM pertaining to this.

    Actually I would debate if this is the wrong forum, as intrinsically RFT (Java)/ Eclipse and Java are some what intertwined.
    >>To be somewhat more helpful

    Thanks. You weren't much more helpful. You told him to do a search and gave him a keyword, which is exactly the same advice I gave.
  • testudo
    testudo
    29 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2009-07-16T06:47:59Z  
    • pabrams
    • ‏2009-07-15T14:44:30Z
    >>To be somewhat more helpful

    Thanks. You weren't much more helpful. You told him to do a search and gave him a keyword, which is exactly the same advice I gave.
    Apologies if I have mistaken the requirements.

    The original requirements -

    1)I want to open excel-sheet in RFT. 2)I want to use excel-sheet in place of conventional data pool and 3) pass the data to my script from the excel only.

    4) I will be very thankful if anybody can pass the script code in java for opening excel in RFT and 5) for reading data from that excel.

    1) They wish to open an excel-sheet in RFT. JXL.JAR achieves this.
    2) He wants to use excel-sheet. Not data pools. So telling him the simplest way is using data pool is at odds with his law.
    3) He wish to pass data to his script. Yet again JXL.JAR achieves this.
    4)JXL.JAR is in written in Java.
    5)JXL.JAR passes data to excel only.

    I actually honestly answered the question to my understanding of the issue posed and did not deflect the question.
  • Raz_Screen
    Raz_Screen
    2 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2009-07-16T08:56:43Z  
    • testudo
    • ‏2009-07-16T06:47:59Z
    Apologies if I have mistaken the requirements.

    The original requirements -

    1)I want to open excel-sheet in RFT. 2)I want to use excel-sheet in place of conventional data pool and 3) pass the data to my script from the excel only.

    4) I will be very thankful if anybody can pass the script code in java for opening excel in RFT and 5) for reading data from that excel.

    1) They wish to open an excel-sheet in RFT. JXL.JAR achieves this.
    2) He wants to use excel-sheet. Not data pools. So telling him the simplest way is using data pool is at odds with his law.
    3) He wish to pass data to his script. Yet again JXL.JAR achieves this.
    4)JXL.JAR is in written in Java.
    5)JXL.JAR passes data to excel only.

    I actually honestly answered the question to my understanding of the issue posed and did not deflect the question.
    Hi,

    You can use the below code to take input from excel sheet instead of RFT Datapool:
    First of all go to Control panel>administrative tools and Create a DSN over there.I have created a DSN(*exceltest*)and map it to the excel sheet from where you want to take input at run time.

    import java.io.*;
    import java.sql.*;

    public class ExcelRead{

    public static void main(String[] args){
    Connection connection = null;

    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection( "jdbc:odbc:exceltest" );
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery( "Select * from Sheet1$" );

    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();

    while (rs.next()) {

    {
    //Use these values wherever you need
    String username= rs.getString("uname");
    String password= rs.getString("pwd");

    }
    System.out.println("");
    }

    st.close();
    con.close();

    } catch(Exception ex) {
    System.err.print("Exception: ");
    System.err.println(ex.getMessage());
    }
    }
    }
    Thanks & Regards
    Sarfaraz Alam
  • pabrams
    pabrams
    664 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2009-07-16T13:20:50Z  
    • testudo
    • ‏2009-07-16T06:47:59Z
    Apologies if I have mistaken the requirements.

    The original requirements -

    1)I want to open excel-sheet in RFT. 2)I want to use excel-sheet in place of conventional data pool and 3) pass the data to my script from the excel only.

    4) I will be very thankful if anybody can pass the script code in java for opening excel in RFT and 5) for reading data from that excel.

    1) They wish to open an excel-sheet in RFT. JXL.JAR achieves this.
    2) He wants to use excel-sheet. Not data pools. So telling him the simplest way is using data pool is at odds with his law.
    3) He wish to pass data to his script. Yet again JXL.JAR achieves this.
    4)JXL.JAR is in written in Java.
    5)JXL.JAR passes data to excel only.

    I actually honestly answered the question to my understanding of the issue posed and did not deflect the question.
    What 'law' are you talking about? And why insult me? And I never mentioned data pools....?? Maybe we could take this discussion offline. Send me your email.
  • testudo
    testudo
    29 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2009-07-17T03:18:28Z  
    • pabrams
    • ‏2009-07-16T13:20:50Z
    What 'law' are you talking about? And why insult me? And I never mentioned data pools....?? Maybe we could take this discussion offline. Send me your email.
    Pabram,

    Apologies if I insulted anyone. I was only trying to assist smeagol in his problem posed.

    I was also aware that you never mentioned datapools.

    Unfortunately I now realise that when you reply in these forums it puts up a replying to: . Which could be taken as a direct retort to the individual and this can as I now realise as an insult.

    However my last post was intended as an apology in the way of attempting to explain myself and understanding of the original problem posed. I was unaware that it would have been taken as a direct insult.

    The word 'law' has numerous meanings possibly I should have used a better choice of words, such as requirement specifications.

    However I note that Razor has provided working code. Which I have also assimilated. As mentioned I was in only trying to assist smeagol.

    Thanks and regards,

    S
  • testinghelp
    testinghelp
    2 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2011-07-15T07:39:19Z  
    Hi,

    You can use the below code to take input from excel sheet instead of RFT Datapool:
    First of all go to Control panel>administrative tools and Create a DSN over there.I have created a DSN(*exceltest*)and map it to the excel sheet from where you want to take input at run time.

    import java.io.*;
    import java.sql.*;

    public class ExcelRead{

    public static void main(String[] args){
    Connection connection = null;

    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection( "jdbc:odbc:exceltest" );
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery( "Select * from Sheet1$" );

    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();

    while (rs.next()) {

    {
    //Use these values wherever you need
    String username= rs.getString("uname");
    String password= rs.getString("pwd");

    }
    System.out.println("");
    }

    st.close();
    con.close();

    } catch(Exception ex) {
    System.err.print("Exception: ");
    System.err.println(ex.getMessage());
    }
    }
    }
    Thanks & Regards
    Sarfaraz Alam
    Hello,
    I am getting the below issue after creating new DSN and excel sheet & mapping it to the dsn.
    Exception occurred during playback of script ExcelRead [CRFCN0670E: RationalTestScriptException on line 0 of script ExcelRead - com.rational.test.ft.MethodNotFoundException: ExcelRead.testMain(http://Ljava.lang.Object;)..
  • testinghelp
    testinghelp
    2 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2011-07-15T07:39:52Z  
    Hi,

    You can use the below code to take input from excel sheet instead of RFT Datapool:
    First of all go to Control panel>administrative tools and Create a DSN over there.I have created a DSN(*exceltest*)and map it to the excel sheet from where you want to take input at run time.

    import java.io.*;
    import java.sql.*;

    public class ExcelRead{

    public static void main(String[] args){
    Connection connection = null;

    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection( "jdbc:odbc:exceltest" );
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery( "Select * from Sheet1$" );

    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();

    while (rs.next()) {

    {
    //Use these values wherever you need
    String username= rs.getString("uname");
    String password= rs.getString("pwd");

    }
    System.out.println("");
    }

    st.close();
    con.close();

    } catch(Exception ex) {
    System.err.print("Exception: ");
    System.err.println(ex.getMessage());
    }
    }
    }
    Thanks & Regards
    Sarfaraz Alam
    Hello,
    I am getting the below issue after creating new DSN and excel sheet & mapping it to the dsn:-
    "Exception occurred during playback of script ExcelRead [CRFCN0670E: RationalTestScriptException on line 0 of script ExcelRead - com.rational.test.ft.MethodNotFoundException: ExcelRead.testMain(http://Ljava.lang.Object;).."
    could you please help?
  • Sathish804
    Sathish804
    1369 Posts

    Re: How to open and read data from excel in RFT ?

    ‏2011-07-15T10:02:29Z  
    Hello,
    I am getting the below issue after creating new DSN and excel sheet & mapping it to the dsn:-
    "Exception occurred during playback of script ExcelRead [CRFCN0670E: RationalTestScriptException on line 0 of script ExcelRead - com.rational.test.ft.MethodNotFoundException: ExcelRead.testMain(http://Ljava.lang.Object;).."
    could you please help?
    JExcel will be much easy to use..try it to handle the Excel sheets.