The xls contain data. how to get number of columns form
the sheet?

Answers were Sorted based on User's Feedback



The xls contain data. how to get number of columns form the sheet?..

Answer / uday

strFilePath="D:\EmpDetails.xls"
Dim fileSysObj
Set xlObj=createobject("Excel.application")
Set xlWorkBookObj=xlObj.workbooks.open(strFilePath)
Set xlWorkSheetObj=xlWorkBookObj.worksheets(1)

intRowCount=xlWorkSheetObj.UsedRange.rows.count 'intRowCount
=xlWorkSheetObj.rows.count - it returns the number of rown
in an Excel sheet

intColCount=xlWorkSheetObj.UsedRange.columns.count
' intColCount=xlWorkSheetObj.columns.count - it returns the
number of columns in an Excel sheet

msgbox "No. of rows used "&intRowCount&" and No. of columns
used. "&intColCount

xlWorkBookObj.close
xlObj.application.quit

Set xlObj=nothing
Set xlWorkBookObj=nothing
Set xlWorkSheetObj=nothing

http://hpsqtp.blogspot.com/2009/04/how-to-find-number-of-
rows-and-columns.html

Is This Answer Correct ?    5 Yes 0 No

The xls contain data. how to get number of columns form the sheet?..

Answer / ur

To get the column count use.
allCols = DataTable.GlobalSheet.GetParameterCount
Msgbox allCols

Is This Answer Correct ?    5 Yes 2 No

The xls contain data. how to get number of columns form the sheet?..

Answer / basha

for outside xls sheet we have follow below
datatable.addsheet("Sheetname")
datatable.importsheet("sheetname",sheetid,"sheetpath")
rowcount=datatable.getsheet("sheetname").getrowcount
msgbox(rowcount)

for globalsheet
rowcount=datatabe("GlobalSheet").getrowcount
msgbox (rowcount)

for actionsheet

rowcount=datatable("LocalSheet").getrowcount
msgbox (rowcount)

Is This Answer Correct ?    2 Yes 4 No

The xls contain data. how to get number of columns form the sheet?..

Answer / basha

for global sheet

rowcount=datatable.globalsheet.getrowcount
msgbox (rowcount)


for action sheet

rowcount=datatable.localsheet.getrowcount
msgbox (rowcount)

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More QTP Interview Questions

What is the file extension of the code file & object repository file in QTP?

2 Answers  


Can we use index on view?

0 Answers   Wipro,


What is runtime objects and test objects? What is the difference between them?

7 Answers   IBM,


How to make arguments optional in a function?

2 Answers   Crea,


Deal All, Recently i face one interview question in one company. str="test12@#3456" In This i want to print like special character and numeric ,word in one script please tell me how to write the code for this Thanks Balaji

1 Answers  






When u r running a script , if u get a popup window that describing that u have received a mail to your outlook application. so to avoid the interference of the popup window , which recovery scenario(popup,object state,application hang,system crash) would u use ?

4 Answers   Accenture,


How to suppress warnings from the test results page?

0 Answers  


tell me types of environment variables? what r they? explain details? pls give anwer any one?

2 Answers   IBM,


Give me the Example of standard check point and text check point with syntax?

3 Answers   IMI Soft, IMI Soft Engineering,


i am unable to select an item from combobox using Descriptive programming. can any one give me code for scheduling the ticket using Descriptive programming.

1 Answers  


What is a recovery scenario?

0 Answers  


How does QTP identifies the object in the application?

1 Answers   Crea,


Categories