Ask a Question

Export Data Table values to External File

SOLVED
Krishna_Kumar
Contributor

Export Data Table values to External File

Hi Team,

 

i wanted to export the data table values to an external CSV file or excel file programatically after each and every execution. im using vbscript.

can anyone help me on this ?

 

Kind Regards,

Sathish Kumar K

1 ACCEPTED SOLUTION

Accepted Solutions
tristaanogre
Community Hero

Re: Export Data Table values to External File

A table variable has two properties/methods: ColumnCount and ColumnName.  ColumnName has a parameter for the index of the column, 0 based.  So Project.Variables.tableVar.ColumnName(0) will return the column name of the first column in the table.  Using ColumnCount, you could build a for-loop to iterate through the columns and document the names.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

7 REPLIES 7
tristaanogre
Community Hero

Re: Export Data Table values to External File

By data table values, what do you mean?  Is this a Table type variable in Project.Variables?

 

If so, you can write an iterative for-loop using the table count as the index and use aqFile object to opena and write to a CSV file the values in the table.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
TanyaYatskovska
Community Manager

Re: Export Data Table values to External File

Hi @Krishna_Kumar,

 

You'll need to work with Excel's COM object. There are many examples in the Community - try searching for them. Here is one of topics:

https://community.smartbear.com/t5/TestComplete-Desktop-Testing/How-to-write-to-Excel-file/td-p/1135...

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Krishna_Kumar
Contributor

Re: Export Data Table values to External File

Hi @TanyaYatskovska  and @tristaanogre ,

 

Thank you very much.

i was able to export the data table values to an external excel successfully by using the ole object concepts.

But it would be good if you provide information about how to retrive the datatable column names, because i am able to retrive only the column values.

waiting for your response.

 

Kind Regards,

Sathish Kumar K

TanyaYatskovska
Community Manager

Re: Export Data Table values to External File

Column names from where? from an Excel file?

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Krishna_Kumar
Contributor

Re: Export Data Table values to External File

@TanyaYatskovska ,

 

from project suite variable (Table variable).

 

Kind Regards,

Sathish Kumar K

tristaanogre
Community Hero

Re: Export Data Table values to External File

A table variable has two properties/methods: ColumnCount and ColumnName.  ColumnName has a parameter for the index of the column, 0 based.  So Project.Variables.tableVar.ColumnName(0) will return the column name of the first column in the table.  Using ColumnCount, you could build a for-loop to iterate through the columns and document the names.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

Krishna_Kumar
Contributor

Re: Export Data Table values to External File

@tristaanogre ,

 

Thank you very much for your help.

 

Kind Regards,

Sathish Kumar K

cancel
Showing results for 
Search instead for 
Did you mean: