Create an Excel file and pass the values from Flat File? (for ex:data1.txt,data2.txt )

Answer Posted / prashant puranik

'To transfer the data from flat file to excel. I have used a logic as Flatfile to datatable to excel


Dim fso,myfile,i,row
i=1,row=0
Set fso=Createobject("Scripting.filesystemobject")
Set myfile=fso.OpenTextFile("G:QTP Examplesqtpexamplefile2.txt",1,True)
Datatable.AddSheet("Puranik")
Datatable.GetSheet("Puranik").AddParameter "Prashant" ," "
Do While myfile.AtEndOfStream <> true
row=row+1
Datatable.GetSheet("Puranik").SetCurrentRow(row)
Datatable.Value("Prashant","Puranik")=myfile.ReadLine
Loop
Datatable.Export("G:QTP Examplesqtpexample_file1.xls")
Set myfile=nothing
Set fso=nothing


'Similary i have created i logic to transfer the data from excel to notepad file

Dim fso,i,myfile
Datatable.AddSheet("mysheet")
Datatable.ImportSheet "G:QTP Examplesqtpexample_file2.xls","Sheet1","mysheet"
row=Datatable.GetSheet("mysheet").GetRowCount
Set fso=Createobject("Scripting.filesystemobject")
Set myfile=fso.OpenTextFile("G:QTP Examplesqtpexamplefile3.txt",2,True)
For i=1 to row
Datatable.GetSheet("mysheet").SetCurrentRow(i)
myfile.WriteLine(Datatable.Value("Anuj","mysheet"))
Next
Set myfile=nothing
Set fso=nothing

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between a Function and Action in QTP?

590


Is the qtp course will help to create a virtual object?

1516


What is the file extension of the code file in qtp?

563


How can you handle exceptions in qtp?

535


How can i initiate the objects to find uniquely in OR

1473






What is reusable action?

605


What are the differences between table and db checkpoints?

535


Discuss quicktest professional (qtp) environment?

578


hi i want license key for qtp 9.2 pls its adjust product name : quick test professional locking code :8 - 54A6A license type : seat license maintenance number : 88888888-8888 pls send license key to my email id borusu.ramkumar@gmail.com

3703


What is exact meaning of Database Checkpoint in QTP 9.2 and what are the different types of the database check points?

2267


we use a file extension .properties why is it used and where do we use it plz help me out with detailed explanation and navigation of how to use on the QTP 8.2?

1632


How to call a test from another test?

682


I have enrolled for a QTP course which is a four weekend course.Do you think its a good way to start off learning this tool?What all do i need with me in order to become a pro at using this tool?

1673


How can I find out the cursor position through QTP suppose I am keep tabbing(Pressing the tab key continuously) and stoped at a position Now I want to find out where the cursor position is

6307


What is checkpoints for quicktest professional (qtp)?

579