SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    May 2007
    Location
    Dublin, OH USA
    Posts
    467
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Export data to Excel

    I searched this forum and spent some time reading post but I can't locate the answer to my question. (I have a feeling that it has been posted here before.) If so, please point me to the post and I'll take it from there.

    At the end of my QTP script run I want to capture some data from the application page and export that to excel.

    I would like the code on how to do that.

    Then I want to compare that output data to what I know should be there and place in QTP a pass or fail.

    So my question is really two parts:

    1. Export data to Excel when a script finishes.
    2. Verify that this data is correct.

    Thanks!
    SBsteve
    Using QTP 9.2 on Windows XP

  2. #2
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Export data to Excel

    Look at Reporter.ReportEvent for pass and fail

    For storing the value you can use

    DataTable("ActualValue",dtGlobalSheet) = ....WebEdit().GetROProperty("value")

    And for export you can use either DataTable.Export or DataTable.ExportSheet

  3. #3
    Member
    Join Date
    May 2007
    Location
    Dublin, OH USA
    Posts
    467
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Export data to Excel

    Thanks Tarun, I'll give that a shot.

    If I come up with some useful code, I will post it back in this thread.

    If anyone else would like to comment, it would be appreciated.

    SBsteve

  4. #4
    Member
    Join Date
    May 2007
    Location
    Dublin, OH USA
    Posts
    467
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Export data to Excel

    With Tarun's suggestion, this is how far I have gotten:

    ********************************

    'Date Ordered
    Dim DateOrdered
    DataTable("DateOrdered",dtGlobalSheet) = OracleFormWindow("Sales Order").OracleTabbedRegion("Order Information").OracleTextField("Date Ordered").GetROProperty("value")
    Msgbox DateOrdered

    *********************************

    But when I run that I get this error message:

    "The set DataTable.Value operation failed. The <DateOrdered> column does not exist."

    Now I am assuming that I first grab the data using RO then I store that in my temp Global datatable. Then I export that
    to the external excel document, correct?

    So I need some help on how to store it temporarily in my Global datatable.


    By the way when I use this command:

    Dim DateOrdered
    DateOrdered = OracleFormWindow("Sales Order").OracleTabbedRegion("Order Information").OracleTextField("Date Ordered").GetROProperty("value")
    Msgbox DateOrdered

    The messagebox comes back with the correct date and time from that object.

    SBsteve

  5. #5
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Export data to Excel

    You need first manually add that column to the data table or you need to use AddParameter method. Look in QTP help file for more details

  6. #6
    Member
    Join Date
    May 2007
    Location
    Dublin, OH USA
    Posts
    467
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Export data to Excel

    Ok I seem to be past the hurdle listed above. Here's my code:

    ************************************************** ***

    'Date Ordered results

    Dim DateOrdered

    'Obtain the value for DateOrdered
    DateOrdered = OracleFormWindow("Sales Order").OracleTabbedRegion("Order Information").OracleTextField("Date Ordered").GetROProperty("value")

    'Msgbox DateOrdered
    ' I used the msgbox to T/S earlier

    'Create a new datasheet for DateOrdered
    Variable=DataTable.AddSheet ("Results").AddParameter("DateOrdered", DateOrdered)

    'Export the data from the new datasheet into an excel doc.
    DataTable.ExportSheet "\\<Where the Excel file exist>\QTP scripts\Scripts - UAT1\Key_Basic_Order_One_Multi_Lines_UAT1\Results. xls" ,"Results"

    ************************************************** **

    That works fine. But I have a few concerns:

    1. When I run my script tomorrow will it overwrite the row of data that was just written to the excel document? If so how can I force QTP to check and see if that row has any data, if it does to keep checking for an emapty row then imput data there?

    2. So far I have exported the data for "DateEntered". Next I will export "Customer #" into the same excel document but under a different column name. That shouldn't be a problem right? The data will come from the same script and iteration.

    3. By the way, I already had this excel document created, but when QTP exported the data to the excel document it over wrote the column headers I already had in there. Why is that? It should have only created a new datasheet within QTP.

    Thanks again,
    SBsteve

  7. #7
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Export data to Excel

    1. Check for the value that Exists in data table and then move to the next row Using Getrowcount and SetCurrentRow

    2. Any time you use export the file is overwriten.

    3. You need to use custom code for such situation using Excel COM API. Read about Excel Macro programming or else Search for Excel.Application on the forum

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 12.50%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin 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 06:30 AM.

Copyright BetaSoft Inc.