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

 
Advanced search

18120 Posts in 4741 Topics- by 31743 Members - Latest Member: suuraj
 

Pages: [1]   Go Down
Print
0 Members and 1 Guest are viewing this topic.
Author Topic: Originally asked by chandra    (Read 1611 times)
Dani Vainstein
Administrator
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
Administrator
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: