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

• Re –Engineering the regression testing from 0% to 60% automation. This has saved 4-mandays in every release. what doeas this statement means

2 Answers   Infosys,


can anyone proide me reading material on svit00ef27@yahoo.com please thanx in advance

2 Answers  


does the vb script knowledge is mandatery in testing using QTP

1 Answers  


Hi I know two types of testing processes. 1. Reaquirments stage,test design,code review's, Design review's, Test Plan, Test Cases design, test execution, Defect Reporting and tracking, UAT, Signoff. 2.Test Initiation , Test Plan, Test Design, Execution,Bug tracking, UAT, Sign off.

0 Answers  


can any one tell me How exactly data drivent testing is done in.explain with any example and the exact steps to fallow?

2 Answers  


In qtp,how to interact tool & application build?

1 Answers   Polaris,


What are the Features & Benefits of Quick Test Pro ?

1 Answers   Crea,


how to write regular expression for Date field?

12 Answers   Google,


where do you store the test result?

2 Answers   HCL,


Hi, I want to retrieve the cell data in the WebTable. For that I have defined a new test object under the browser and have given html tag and text as the test object properties. But while I try to identify it it says 'Object description is not unique'. I tried adding innerhtml, outerhtml, innertext and outertext along with the ordinal identifiers; but no use. What more properties need to be added to identify it? Also I want to enable smart identification for this object but the field is disabled in the object repository for this object alone(In QTP tools->object identification the enable smart identification checkbox is enabled). How do I enable it?

3 Answers  


How do we create and run the scripts with out using O.R. ?

5 Answers  


hi all can anyone explain how to write the code for finding the mandatory columns in table which are having (red*) (red Astrik)

0 Answers   Livetek,


Categories