http://quicktesthp.blogspot.com

QTP VBScript new series + Interview Question Bank on QTP for enrichment of Knowledge in QTP

This Site has been brought to you by HP Certified Expert of QTP.

Exciting new articles for October:

1) QTP Tip:Deselect all Radio Buttons

2) HP QTP Crypt Object

3)Adding Hyperlinks in Excel Spreadsheet

Best of Luck Friends ! ! !

Expert QTP
expert.qtp@gmail.com

All Articles are Copyright Protected. These are Free for Reading & Personal Use. Reproduction in Any Form without the Permission is Illegal & Strictly Prohibited.

Copyright © 2009 ExpertQTP

Google Search

Friday, June 6, 2008

Amazing power of QTP for Import & Export of Data from datatable using QTP

Import External Data File

The datatable created by QTP can be exported to an external location. Pretty Cool though….

Now lets see how it is done. Create a new script. Now open your DataTable and right click inside any cell using the mouse. Click File-> Import from File. You will see a screen as shown below.

Click on the OK button. Now navigate to an already existing excel file, select and click Open. With this, your excel file will be opened in the datatable completely. Now every column you create in the excel sheet will become a parameter.

This task can also be accomplished programmatically. For this, use the following syntax.

Datatable.Import(FileName)

Here FileName is the full path of the Excel table to import.

Exporting Datatable to an external File

You guys probably be thinking just like we imported an external excel file into our datatable, is the reverse also true. Yes, it is. We can export our created datatable into an external excel file. This we can do if we want to utilize our existing datatable inside a different script rather than creating it from the scratch again.

Lets see how it is being done. Again, open your datatable and right click on any cell. Select File->Export. Provide the file name and click on the Save button. Wow..You are done.

There is one more way to accomplish the above mentioned task. We can programmatically export our datatable. The syntax for doing the same is:

DataTable.Export(FileName)

Here “FileName” is the full path of the location to which the Data Table should be exported. For example:

DataTable.Export(“C:\Expert.xls”)

Note: For detailed information, you can see the inbuilt help file provided by QTP.

Keywords: QTP, Excel, ExcelSheet, datatable, parameterize

No comments:

 
Copyright © 2009 ExpertQTP