SPONSORS:






User Tag List

Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Jun 2000
    Location
    pune, maharashtra,india
    Posts
    17
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to get data from xls file and assign it to text property of text box.

    Using Silk test for web application.I want to read data from the .xls file which has around 10 attributes. Read data is to be assigned to the various text fields. How can I do it.
    prashant.

  2. #2
    AJ
    AJ is offline
    Moderator AJ's Avatar
    Join Date
    Jun 1999
    Location
    San Jose, CA
    Posts
    1,691
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get data from xls file and assign it to text property of text box.

    You cannot read from an XLS (not to my knowledge anyway) unless you make the file .csv (plain comma delimmeted file). That can be read into Excel. XLS files are binary while CSV are ASCII Text.

    Oh and the only way to read the XLS files I know is to open them in Excel and automate the Excel application.

    ------------------
    AJ Alhait
    BetaSoft Inc.

    [This message has been edited by AJ (edited 06-15-2000).]
    AJ Alhait
    BetaSoft Inc.

  3. #3
    Member
    Join Date
    Jul 1999
    Location
    Raleigh, NC
    Posts
    35
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get data from xls file and assign it to text property of text box.

    You can treat Excel workbooks just like any other database as far as I know.

    Someone in my organization created ODBC and SQL calls in QAParter to read info directly from Excel test matrixes we utilize to create and manage our testcases.

    I can't provide the code, nor have I personally ever attempted to create this code, but I can tell you it works and is very useful.

  4. #4
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get data from xls file and assign it to text property of text box.

    Try this baby it is a beauty: http://customers.segue.com/protected/bronze/s_newsletter/9903/articles/s_1jamesso_to c_.htm

    It's about how to read from excel's .xls files.

    For lazy people

    I hope everyone interest can read this article.

    ------------------


    [This message has been edited by GodKnows (edited 05-24-2001).]

  5. #5
    Member
    Join Date
    May 2001
    Posts
    56
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get data from xls file and assign it to text property of text box.

    Hi Prashant,

    I think it will work.
    Handle HDB
    Handle hSql
    HDB = DB_Connect ("dsn=Excel Files;DBQ=C:\Test\Sample.xls")
    hSql = DB_ExecuteSql (HDB, "SELECT * FROM `Sheet1$`")
    while (DB_FetchNext hSql,sP1,sP2))
    HtmlTextField1.SetText(sP1)
    HtmlTextField2.SetText(sP2)
    DB_FinishSQL(hSql)
    DB_Disconnect(HDB)


    [This message has been edited by mansri (edited 05-24-2001).]

    [This message has been edited by mansri (edited 05-24-2001).]

    [This message has been edited by mansri (edited 05-24-2001).]

  6. #6
    Senior Member
    Join Date
    Nov 2000
    Location
    Bloomington, IL
    Posts
    142
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get data from xls file and assign it to text property of text box.

    I have set up the following functions to do my connection strings and do the initial read to an Excel file and then continue to read.

    Before you start you need to create a new Data Source, to do this
    1. Click on Start/Setting/Control Panel, Select Data Source (ODBC)
    2. Click on the Add button
    3. Choose Excel Driver (*.xls)
    4. Click the Finish button
    5. Enter a Unique DSNfile name (Do not select a workbook, because this will limit you later to a specific file in a specific place, we will handle this pathing in the connection string within SilkTest.)
    6. Click the OK button.
    7. Click OK, you have now created a DSN file that can be referenced from SilkTest.

    The first establishes function creates the connection string (After DSN= replace the current value with the name of the DSN file you created above. After DBQ=replace the path with the path to the Excel file you want to use)
    [+] ExcelConnectString()
    [ ] sConnectString = "DSN=InInput2;DBQ=d:\data\SilkTestClass\AccessInpu t.xls"
    [ ]
    [ ] hDB = DB_Connect(sConnectString)

    The next function returns all columns from the specified Excel file.
    [+] ExcelGetData()
    [ ] STRING sSQL = "SELECT * FROM `Sheet1$` `Sheet1$` "
    [ ]
    [ ] hSQL = DB_ExecuteSQL (hDB,sSQL)

    The next function returns the first record of the dataset requested in the function ExcelGetData. To make this data easier to deal with I turn the list of string into a tab delimited string before parsing the data into its primary parts.

    [+] STRING ExcelCreateString()
    [ ] STRING sData
    [ ] STRING sReturn
    [ ] INTEGER iIndex = 1
    [ ]
    [-] while (DB_FetchNext (hSQL, lsData))
    [-] for each sData in lsData
    [-] if iIndex == 1
    [ ] sReturn = sData
    [-] else
    [ ] sReturn = sReturn + " " + sData
    [ ] iIndex++
    [ ] return sReturn
    [ ] sReturn = "Finished"
    [ ] DB_FinishSQL(hSQL)
    [ ] return sReturn

    The last function parses the data into variables that can be used within your SilkTest script.

    [+] SetEFields(STRING sRecord)
    [ ] sFName = GetField (sRecord, " ", 1)
    [ ] sLName = GetField (sRecord, " ", 2)
    [ ] sAddress = GetField (sRecord, " ", 3)
    [ ] sCity = GetField (sRecord, " ", 4)
    [ ] sState = GetField (sRecord, " ", 5)
    [ ] sZip = GetField (sRecord, " ", 6)

    I call these functions from within a loop at the beginning of my script to set my data before I start.

    I hope this gives you a little more information about using xls files for input.

    Mike



    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:46 AM.

Copyright BetaSoft Inc.