Skip to main content

Data Table Query Class

Download Add-in for Office Guide

The Data Table Query class represents a data table query created using the Data Table Query menu option. You can use the properties and methods of this class to create a new data table query, modify an existing query, and output the query results to a Microsoft Excel worksheet.

Property Summary

  • Property ApplyFormatting As Boolean
  • Property ApplyNegativeColor As Boolean
  • Property DecimalPlaces As Long
  • Property NegativeFormat As String
  • Property SymbolOutput as SymbolOutput
  • Property TableName As String
  • Property UseThousandsSeparator As Boolean

Sub/Function Summary

  • Sub AddColumn(columnName as String, [decimalPlaces as Long])
  • Sub ClearColumns()
  • Sub LoadQuery(queryFileName as String)
  • Sub RunToWorksheet([worksheetName as String], [cell As String])

Properties

Parameter Description

ApplyFormatting

Property ApplyFormatting As Boolean

Specifies whether the custom number formatting is applied to numbers in the results. The default value is FALSE.

If the value is set to TRUE, the values of the DecimalPlaces, UseThousandsSeparator, NegativeFormat and ApplyNegativeColor properties will be applied to numbers in the query.

ApplyNegativeColor

Property ApplyNegativeColor As Boolean

Specifies whether negative colors will be rendered in Red.  The default value is FALSE.

DecimalPlaces

Property DecimalPlaces As Long

Specifies the number of decimals to show for each numeric data cell.  The default value is 0. Valid values range from 0 to 9.

NegativeFormat

Property NegativeFormat As String

A number format string representing how negative numbers will be formatted. 

See Excel documentation on valid string formats.

SymbolOutput

Property SymbolOutput As SymbolOutput

Specifies whether the query results include symbol name, symbol description or both. 

  • SymbolOutput_Name – Query results display symbol name. This is the default.
  • SymbolOutput_Description – Query results display symbol description
  • SymbolOutput_NameAndDescription - Query results display both name and description.

TableName

Specifies the name of the data table to query. The value must match the name of an existing data table in the Longview application.

UseThousandsSeparator

Property UseThousandsSeparator As Boolean

Specifies whether thousands separators are used when formatting numbers.

Sub/Functions

Parameter Description

AddColumn

Sub AddColumn(columnName As String, [decimalPlaces As Long])

Adds a column to the data table query.

Parameters:

  • columnName – Required. A string representing the name of the data table column to add to the query.
  • decimalPlaces – Optional. A long integer specifying the number of decimal places to display for numeric columns. If not specified, the default formatting is used.

Errors:

  • ErrorCode.INVALID_PARAMETER – Thrown if the specified column name is invalid or does not exist in the selected data table.

ClearColumns

Sub ClearColumns()

Removes all currently selected columns from the data table query. This method does not remove the selected data table or any other query settings.

LoadQuery

Sub LoadQuery(queryFileName As String)

Loads a previously saved data table query.

Parameters:

  • queryFileName – Required. A string representing the full path to the query file to load. For example: C:\DataTableQuery.lvdtq.

Errors:

  • ErrorCode.INVALID_PARAMETER – Thrown if the specified query file cannot be loaded.

RunToWorksheet

Sub RunToWorksheet([worksheetName As String], [cell As String])

Runs the data table query and inserts the results into the specified worksheet and starting cell.

Parameters:

  • worksheetName – Optional. A string representing the name of the worksheet in which to place the query results. If the worksheet does not exist, it is created. If this parameter is omitted, the current worksheet is used.
  • cell – Optional. A string representing the starting cell for the query results. If this parameter is omitted, the default cell location A1 is used.

Errors:

  • ErrorCode.INVALID_PARAMETER – Thrown if the query is invalid or if the specified worksheet name or cell reference is invalid.

Sample Usage:

Dim query As Longview.DataTableQuery

Set query = New Longview.DataTableQuery

query.TableName = "LVAPP_TASKS"

query.ApplyFormatting = True

query.DecimalPlaces = 0

query.UseThousandsSeparator = True

query.NegativeFormat = "(1234)"

query.ApplyNegativeColor = True

query.SymbolOutput = SymbolOutput_NameAndDescription

query.AddColumn("ID")

query.AddColumn("Amount", 2)

query.RunToWorksheet("TasksWorksheet", "B2")

Was this article helpful?

We're sorry to hear that.