Skip to main content
Version: 20 R5

VP ADD STYLESHEET

VP ADD STYLESHEET ( vpAreaName : Text ; styleName : Text ; styleObj : Object { ; sheet : Integer } )

ParameterTypeDescription
vpAreaNameText->4D View Pro area form object name
styleNameText->Name of style
styleObjObject->Object defining attribute settings
sheetInteger->Sheet index (current sheet if omitted)

Description

The VP ADD STYLESHEET command creates or modifies the styleName style sheet based upon the combination of the properties specified in styleObj in the open document. If a style sheet with the same name and index already exists in the document, this command will overwrite it with the new values.

Style sheets created by this command are saved with the document.

In vpAreaName, pass the name of the 4D View Pro area. If you pass a name that does not exist, an error is returned.

The styleName parameter lets you assign a name to the style sheet. If the name is already used within the same scope, the new style sheet replaces the existing one. Note that you can use the same name for different scopes (see below).

Within the styleObj, designate the settings for the style sheet (e.g., font, text decoration, alignment, borders, etc.). For the full list of style properties, see Style object properties.

You can designate where to define the style sheet in the optional sheet parameter using the sheet index (indexing starts at 0) or with the following constants:

  • vk current sheet
  • vk workbook

If a styleName style sheet is defined at the workbook level and at a sheet level, the sheet level has priority over the workbook level when the style sheet is set.

To apply the style sheet, use the VP SET DEFAULT STYLE or VP SET CELL STYLE commands.

Example

The following code:

$styles:=New object
$styles.backColor:="green"

//Line Border Object
$borders:=New object("color";"green";"style";vk line style medium dash dot)

$styles.borderBottom:=$borders
$styles.borderLeft:=$borders
$styles.borderRight:=$borders
$styles.borderTop:=$borders

VP ADD STYLESHEET("ViewProArea";"GreenDashDotStyle";$styles)

//To apply the style
VP SET CELL STYLE(VP Cells("ViewProArea";1;1;2;2);New object("name";"GreenDashDotStyle"))

will create and apply the following style object named GreenDashDotStyle:

{
backColor:green,
borderBottom:{color:green,style:10},
borderLeft:{color:green,style:10},
borderRight:{color:green,style:10},
borderTop:{color:green,style:10}
}

See also

4D View Pro Style Objects and Style Sheets
VP Get stylesheet
VP Get stylesheets
VP REMOVE STYLESHEET
VP SET CELL STYLE
VP SET DEFAULT STYLE