How to new style

Posted by: 122368177 on 29 April 2020, 10:50 pm EST

    • Post Options:
    • Link

    Posted 29 April 2020, 10:50 pm EST

    ts

    export class Style{

    constructor(backColor?: string, foreColor?: string, hAlign?: GC.Spread.Sheets.HorizontalAlign, vAlign?: GC.Spread.Sheets.VerticalAlign, font?: string, themeFont?: string, formatter?: string | GC.Spread.Formatter.GeneralFormatter, borderLeft?: GC.Spread.Sheets.LineBorder, borderTop?: GC.Spread.Sheets.LineBorder, borderRight?: GC.Spread.Sheets.LineBorder, borderBottom?: GC.Spread.Sheets.LineBorder, locked?: boolean, textIndent?: number, wordWrap?: boolean, shrinkToFit?: boolean, backgroundImage?: string, cellType?: GC.Spread.Sheets.CellTypes.Base, backgroundImageLayout?: GC.Spread.Sheets.ImageLayout, tabStop?: boolean, textDecoration?: GC.Spread.Sheets.TextDecorationType, imeMode?: GC.Spread.Sheets.ImeMode, name?: string, parentName?: string, watermark?: string, cellPadding?: string, labelOptions?: GC.Spread.Sheets.ILabelOptions, diagonalDown?: GC.Spread.Sheets.LineBorder, diagonalUp?: GC.Spread.Sheets.LineBorder, isVerticalText?: boolean, textOrientation?: number);

    const style = new GC…Style(key1,key2,)…

    How can I init style with object params. new GC…Style({key1:ssss})

    unless I need to “for in” the params

    style.key1 = params.key1

    style.key2 = params.key2

    thanks~

  • Posted 30 April 2020, 10:27 am EST

    Hi,

    Since Style constructor doesn’t expect any object parameter you could not pass the object to the style constructor however what you could do is loop through your params object and set it to the style object one by one as demonstrated in the following code snippet and the sample:

    var style = new GC.Spread.Sheets.Style();
      for (let key of Object.keys(parmaOBJ)) {
        style[key] = parmaOBJ[key];
      }
    

    sample: https://codesandbox.io/s/spread-js-starter-uuyke

    Regards

  • Posted 6 May 2020, 10:54 pm EST

    Thanks ~

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels