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

Out of 3 recording modes. 1.Standard 2.Analog 3.Low-level, which one is commonly used. As per my knowledge, Analog is used for Graphs , barcoding or DIgital signatures.

0 Answers  


What is Virtual object wizard in QTP?

4 Answers  


What's QuickTest Window?

1 Answers  


Hi every body, I am new to QTP.pls help me if anybody knows the solution. Here is my doubt: I have 3 excel sheets in my local drive out of which one is password protected and i want to get the data of all these xL's either by importing or by reading the data finally i have to update this data in the website.(and the site is secured site) I tried by importing all XL"s one by one but couldn't do so. plss send me the code or atleast suggest me the approach. Thanks in Advance Padmaja

3 Answers   Symphony,


suppose take one row in a row 16 columns is there.in 16 columns 16 numbers is there.but i want to get each 3 column number.o/p :5 columns get in 16 columns means. so can anybody write this function? plz send if u know the answer.

2 Answers   Bosch,






Does QTP provides any tools for parametarization?

3 Answers   BirlaSoft,


It seems Interview questions from Ordain Solutions are almost BASIC LEVEL-Easy. I am asking one tough question..(I think.. May be easy for some people) In recorded script the - WebLink("cityinfo") In reality, the WebLink name is "generalinfo" How you can write function to click that changed web link. NOTE: This functin should work with any Dynamic text link. I will post the answer later.

8 Answers  


How to count no of edit boxes on the page?

3 Answers   IBM,


1) How will you associate SOR in Runtime? ( u had written 10 lines of code from 11th line u want associate what code u will write) 2) How will close n number of browser expect only one which is has to test? ( First tell me how will you identify how many browser are opened ) what logic u will use? 3) In web Table u want to click on link ( Link Name Mohamed ) you dont know in which row and column that link is there. how wil u identify and click on that link.

2 Answers  


In Remote acess server how u run a test?

0 Answers  


I am new with QTP. Is anybody could tell me where I can find a good tutorial with lots of samples?

0 Answers  


Hi All, How to get repeated word in string . Thanks Balaji

0 Answers  


Categories