workbook.createStyle(options)

Method Description

Creates a style to be used for conditional formatting.

Returns

workbook.Style

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/workbook Module

Sibling Module Members

N/workbook Module Members

Since

2021.2

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.backgroundColor

workbook.Color | string

optional

The background color.

options.backgroundImage

string

optional

The background image.

options.backgroundPosition

workbook.PositionPercent | workbook.PositionUnits | workbook.PositionValues

optional

The background position.

options.color

workbook.Color | string

optional

The font color.

options.fontSize

workbook.FontSize

optional

The font size.

options.fontStyle

workbook.FontStyle

optional

The font style.

options.fontWeight

workbook.FontWeight

optional

The font weight.

options.textAlign

workbook.TextAlign

optional

The alignment of text.

options.textDecorationColor

workbook.Color | string

optional

The text decoration color.

options.textDecorationLine

workbook.TextDecorationLine

optional

The text decoration line.

options.textDecorationStyle

workbook.TextDecorationStyle | string

optional

The text decoration style.

Errors

Error Code

Thrown If

INVALID_COLOR

The value of any of the options.backgroundColor, options.color, or options.textDecorationColor parameters is not included in the workbook.Color enum and is not a workbook.Color object.

INVALID_FONT_SIZE

The value of the options.fontSize parameter is not included in the workbook.FontSize enum.

INVALID_FONT_STYLE

The value of the options.fontStyle parameter is not included in the workbook.FontStyle enum.

INVALID_FONT_WEIGHT

The value of the options.fontWeight parameter is not included in the workbook.FontWeight enum.

INVALID_IMAGE

The value of the options.backgroundImage parameter is not included in the workbook.Image enum.

INVALID_TEXT_ALIGN

The value of the options.textAlign parameter is not included in the workbook.TextAlign enum.

INVALID_TEXT_DECORATION_LINE

The value of the options.textDecorationLine parameter is not included in the workbook.TextDecorationLine enum.

INVALID_TEXT_DECORATION_STYLE

The value of the options.textDecorationStyle parameter is not included in the workbook.TextDecorationStyle enum.

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/workbook Module Script Samples. Also see Full scripts in the Tutorial: Creating a Workbook Using the Workbook API topic.

            //Add additional code
...
var newStyle = workbook.createStyle({
    backgroundColor: workbook.Color.WHITE, // backgroundColor: 'WHITE' also works
    backgroundImage: 'myStyleImage',   // this value must be previously defined
    backgroundPosition: workbook.createPositionPercent ({
        percentX: 25,
        percentY: 45
    }),
    color: workbook.Color.BLUE, // color: 'BLUE' also works
    fontSize: workbook.FontSize.MEDIUM, 
    fontStyle: workbook.FontStyle.NORMAL,
    fontWeight: workbook.FontWeight.BOLD,
    textAlign: workbook.TextAlign.CENTER,
    textDecorationColor: workbook.Color.YELLOW,
    textDecorationLine: workbook.TextDecorationLine.UNDERLINE,
    textDecorationsStyle: workbook.TextDecorationStyle.WAVY 
});
...
// Add additional code 

          

Related Topics

General Notices