ColumnCount Property

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

Use the ColumnCount property to obtain the number of columns for the storage to which ProgObj provides access. For information on how TestComplete determines the total column number, see Using DDT Drivers.

Declaration

ProgObj.ColumnCount

Read-Only Property Integer
ProgObj An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section

Applies To

The property is applied to the following object:

Property Value

An integer value specifying the number of columns.

Example

The code below specifies new Excel drivers and then posts the names of all the columns accessed by the driver to the test log.

JavaScript, JScript

function ColumnName()
{
  // Specifies two new Excel drivers
  var Driver = DDT.ExcelDriver("C:\\MyFiles\\1.xls", "Sheet1");
  var ColNum = Driver.ColumnCount;
  
  // Iterates through the columns
  for (var i = 0; i < ColNum; i++)
  {
    var ColName = Driver.ColumnName(i);
    // Posts a column name to the test log
    Log.Message("The name of the " + (i+1) + " column is: " + ColName);
  }
}

Python

def ColumnName():
  # Specifies two new Excel drivers 
  Driver = DDT.ExcelDriver("C:\\MyFiles\\1.xls", "Sheet1");
  ColNum = Driver.ColumnCount;
  # Iterates through the columns 
  for i in range(0, ColNum):
    ColName = Driver.ColumnName[i]
    # Posts a column name to the test log 
    Log.Message("The name of the " + str(i + 1) + " column is: " + str(ColName))

VBScript

Sub ColumnName

  ' Specifies two new Excel drivers
  Set Driver = DDT.ExcelDriver("C:\Documents and Settings\User\Desktop\1\1.xls", "Sheet4")
  ColNum = Driver.ColumnCount
  
  ' Iterates through the columns
  For i = 0 to (ColNum - 1)
    ColName = Driver.ColumnName(i)
    ' Posts a column name to the test log
    Log.Message("The name of the " & (i+1) & " column is: " & ColName)
  Next
  
End Sub

DelphiScript

function ColumnName;
var Driver, ColNum, i, ColName;
begin

  // Specifies two new Excel drivers
  Driver := DDT.ExcelDriver('C:\MyFiles\1.xls', 'Sheet1');
  ColNum := Driver.ColumnCount;
  
  // Iterates through the columns
  for i := 0 to (ColNum - 1) do
  begin
    ColName := Driver.ColumnName[i];
    // Posts a column name to the test log
    Log.Message('The name of the ' + IntToStr(i+1) + ' column is: ' + ColName);
  end;

end;

C++Script, C#Script

function ColumnName()
{
  // Specifies two new Excel drivers
  var Driver = DDT["ExcelDriver"]( "C:\\MyFiles\\1.xls", "Sheet1" );
  var ColNum = Driver["ColumnCount"];
  
  // Iterates through the columns
  for (var i = 0; i < ColNum; i++)
  {
    var ColName = Driver["ColumnName"](i);
    // Posts a column name to the test log
    Log["Message"]( "The name of the " + (i+1) + " column is: " + ColName );
  }
}

See Also

ColumnName Property
Value Property
Using DDT Drivers

Highlight search results