SPONSORS:






User Tag List

Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    Jul 2000
    Location
    sanjose,ca,usa
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem in reading data from xls

    Hi
    I have written the following code for reading a particular column from xls sheet,it is not working there is a minor problem,here is the code
    HFILE hFile
    STRING CustName
    hFile=Fileopen("mydata1.xls",FM_READ)
    while(FileReadLine(hFile,CustName)
    print(CustName)
    FileClose(hFile)
    any help
    Thanks
    srini

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

  2. #2
    bjc
    bjc is offline
    Member
    Join Date
    Jan 2000
    Location
    CT
    Posts
    66
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: problem in reading data from xls

    You have to treat Excel files as databases. See the db_ functions in the reference guide. There are also a lot of posts on this subject. Try searching on "Excel".

    Here is a post that might help you get started: http://www.qaforums.com/Forum1/HTML/001760.html


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

  3. #3
    Member
    Join Date
    Jul 2000
    Location
    sanjose,ca,usa
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: problem in reading data from xls

    Hi bjc
    Thanks for your reply,i had used this code
    [-] testcase getdataxls() appstate none
    [1 ] HANDLE hDB
    [2 ] HANDLE hSQL
    [3 ] STRING Custno
    [4 ] hDB=DB_connect("dsn=SilkTest_Data")
    [5 ] print("Connected to database")
    [6 ] STRING sSQL="SELECT * from 'mydata$','mydata$'"
    [7 ] hSQL=DB_ExecuteSQL(hDB,sSQL)
    [8] while DB_FetchNext(hSQL,Custno)
    [9 ] Print(Custno)
    [10 ] DB_FinishSql(hSQL)
    [11 ] DB_Disconnect(hDB)
    It is giving error as invalid query statement at line 6,i even used STRING sSQL="SELECT * from 'mydata$'"
    can i get solution for this
    sri



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

  4. #4
    Senior Member
    Join Date
    Oct 2000
    Location
    Laurel, Maryland, USA
    Posts
    204
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: problem in reading data from xls


    We had a problem with the 'Select *' part of the SQL query. I would think this should work, but it didn't for us. We changed our query to select the named columns that we needed - i.e 'Select Table1, Table2, Table3 from ...'



    ------------------
    Atlee
    Atlee

  5. #5
    Senior Member
    Join Date
    Jun 2000
    Location
    Chicago, IL USA
    Posts
    383
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: problem in reading data from xls

    SriReddy:

    If you don't want to deal with all of the SQL database stuff and want a simple, more portable solution, do the following:
    Instead of saving your file in Microsoft's proprietary ".XLS" format -- use "Save As" to save it in the universally accepted ".CSV" format.

    You would lose any pretty formatting in the spreadsheet (if you had any), but you could read the data with your original script -- with the addition of GetField() to isolate your column data.



    ------------------
    Rob Kapteyn
    Rob Kapteyn, CSTE
    RobKapteyn@gmail.com

  6. #6
    bjc
    bjc is offline
    Member
    Join Date
    Jan 2000
    Location
    CT
    Posts
    66
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: problem in reading data from xls

    try changing
    "SELECT * from 'mydata$','mydata$'"
    to
    "SELECT * from `mydata$`"
    note: this ` (tilde key slanted quote) is different from this ' (single quote)

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

  7. #7
    Member
    Join Date
    Jul 2000
    Location
    sanjose,ca,usa
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: problem in reading data from xls

    Hi bjc
    Haaaa.. it worked ,i could not identify the difference between ` and '.
    Thanks
    sri

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

 

 

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 02:33 PM.

Copyright BetaSoft Inc.