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

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

There are 10 rows in the datatable. How can we fetch 2 rows and then skip 3rd row. After that, pick 4th & 5th row and skip 6th row. Please share code

1215


PLEASE TELL ME WHEN DO YOU USE THE OBJECT SPY AT RUN TIME

5972


Name the different types of recording modes?

583


What are the steps involved in the recovery scenario wizard?

565


How can you close the second opened browser?

807






what are the frame work models of qtp?which frame work you follow in your company?and explain it process?

1970


Client is able to provide budget..he want you to choose the automation tool for the web application? which one you will select ? QTP or Selenium ? what are the reasons?

1233


What are table and db checkpoints?

592


Describe function procedure in vbscript.

562


I had installed QTP 9.2. It is working fine but whenever I open QTP, it is trying to reinstall the below-mentioned files again and again "QTP92PS82UPGRADE.exe", "recogn.dll". If anybody has these files, please provide those files in this site or you can send that files to my mail id also (lravi4u@yahoo.com). If you don't know where the files will be in the QTP, search in the QTP software CD or path of QTP program installed (C:\Program Files\Mercury Interactive\QuickTest Professional)

1469


Explain the terms test and business component?

553


What is action? How many types of actions are there in qtp?

620


What is method name to compare two XML files.

1543


what is stepin & stepout?

1429


Can QTP be used for GUI testing ?, We are using Java with MySQL and Operating system is Linux. We are NOT using the web.

1949