Welcome, Guest. Please login or register.
Login with username, password and session length

 
Advanced search

18488 Posts in 4838 Topics- by 32654 Members - Latest Member: revitvm
 

AdvancedQTP forums have been nominated as a finalist in ATI’s 2nd annual automation honors awards!

We’d like to thank you for your continued support and participation, and urge you to hurry and vote.

Make you voice count! 


Pages: [1]   Go Down
Print
0 Members and 1 Guest are viewing this topic.
Author Topic: Originally asked by chandra    (Read 1659 times)
Dani Vainstein
Advanced User
*****
Offline Offline

Posts: 623



« on: October 19, 2007, 02:40:14 AM »

how to count no. of cloumns in an excel sheet?
Logged

Best Regards,
Dani Vainstein
Mercury CPC

http://www.advancedqtp.com
Yuval Keren
FRProject
User
*
Offline Offline

Posts: 2


« Reply #1 on: October 19, 2007, 02:46:27 PM »

Code
GeSHi (qtp):
'This is a pure vbscript to get the no' of columns:



'Create an Excel Object model

Set ExcelFile = CreateObject("Excel.Application")

'You can set it to false as well

ExcelFile.Visible = true

'Open the Excel file

ExcelFile.Workbooks.Open "C:\Demo.xls"

'Get the 1st sheet (can be change to some other index number)

Set ExcelSheet = ExcelFile.Sheets.Item(1)

'Get the number of columns

Cols = ExcelSheet.UsedRange.Columns.Count



msgbox "No of Columns: " & Cols



Set ExcelSheet = nothing

ExcelFile.Quit

Set ExcelFile = nothing

 
Created by GeSHI 1.0.7.20
« Last Edit: October 19, 2007, 08:42:30 PM by Site Administrator » Logged
Dani Vainstein
Advanced User
*****
Offline Offline

Posts: 623



« Reply #2 on: October 19, 2007, 04:54:49 PM »

Is the UsedRange property includes Empty String cells? or only unused cells?
Logged

Best Regards,
Dani Vainstein
Mercury CPC

http://www.advancedqtp.com
Pages: [1]   Go Up
Print
Jump to: