Styles

Styles help you customize cell formats in table views and pivots based on conditions. You can create standalone styles to customize cell attributes, and then add them to formatting rules.

For more information about styles in SuiteAnalytics Workbook, see Conditional Formatting.

You can create a standalone style using workbook.createStyle(options). This method creates a workbook.Style object. You can also provide these optional parameters to workbook.createStyle(options):

          var myFirstStyle = workbook.createStyle({
    backgroundColor: workbook.createColor({
        red: 255,
        green: 192,
        blue: 203
    })
});

var mySecondStyle = workbook.createStyle({
    fontSize: workbook.FontSize.LARGE,
    fontStyle: workbook.FontStyle.ITALIC,
    fontWeight: workbook.FontWeight.BOLD
}); 

        

To create a report style, start by creating report style rules using workbook.createReportStyleRule(options), similar to creating conditional formatting rules for a conditional format. This creates a workbook.ReportStyleRule object. You'll need to provide these parameters:

          var myReportStyleRule = workbook.createReportStyleRule({
    expression: workbook.createExpression({
        functionId: workbook.ExpressionType.COMPARE,
        parameters: {
            comparisonType: 'GREATER_OR_EQUAL',
            operand1: workbook.createExpression({
                functionId: workbook.ExpressionType.MEASURE_VALUE,
                parameters: {
                    measure: myCalculatedMeasure
                }
            }),
            operand2: workbook.createConstant(
                workbook.createCurrency({
                    amount: 1,
                    id: 'USD'
                })
            )
        }
    }),
    style: workbook.createStyle({
        backgroundColor: workbook.createColor({
            red: 255,
            green: 192,
            blue: 203
        })
    })
}); 

        

When you have your report style rules, use workbook.createReportStyle(options) combine them into a single workbook.ReportStyle object. You'll also need to provide a selector to choose the cell in the pivot where the style will be applied. For more information, see Selectors.

          var conditionalRowSelector = workbook.DescendantOrSelfNodesSelector;
var conditionalColumnSelector = workbook.DescendantOrSelfNodesSelector;
var conditionalMeasureSelector = workbook.createMeasureSelector({
    measures: [myCalculatedMeasure]
});

var measureValueSelector = workbook.createMeasureValueSelector({
    rowSelector: conditionalRowSelector,
    columnSelector: conditionalColumnSelector,
    measureSelector: conditionalMeasureSelector
});

var myReportStyle = workbook.createReportStyle({
    selectors: [measureValueSelector],
    rules: [myFirstReportStyleRule, mySecondReportStyleRule]
}); 

        

Related Topics

General Notices