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

Answers were Sorted based on User's Feedback



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

Answer / prashant puranik

'programme to transfer the data from notepad 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")

'Programme to transfer the data from excel file to notepad
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 ?    2 Yes 0 No

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

Answer / 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

More QTP Interview Questions

How u send bugs to dev'lpment team all at once or one by one or waht is the process?

2 Answers   kenexa,


What is VSS? Is it used in Automation(QTP) Or Manual? what is menus in VSS?

3 Answers   TCS,


Describe the differences between functions and actions in UFT?

0 Answers  


How can you identify the browser and its information using QTP script?

0 Answers  


Where is the Bitmap checkpoint information stored?

0 Answers   Ordain Solutions,






Please provide specific examples of advanced/creative usage of QTP, including how impact & benefits for your project

0 Answers   T Mobile,


How do Parameterization and Data-Driving relate to each other in QTP?

0 Answers  


Pls anyone, tell me the script in QTP to find the number of links, and images in a webpage. Verry very urgent. I shall really be very thankful

3 Answers  


How to import a test case present in ".xls" file to TD under a Test set?

0 Answers  


How can we disable popup blocker?

1 Answers  


Is it mandatory to know abt regular expression in descriptive programming

2 Answers  


What are advantages of test automation?

0 Answers  


Categories