We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to add custom property (object type) to a column?

Hi , 


I am looking for a way to add custom property that will be object type to a column in my spreadsheet project  (like color,width ,..).

if such option exist in Syncfusion spreadsheet angular , please add example of the code.



Thank you



1 Reply

SP Sangeetha Priya Murugan Syncfusion Team November 8, 2022 10:57 AM UTC

Hi Dov,


We haven’t provided cell formatting support for the whole column. However, your requirement can be met by using the queryCellInfo event and the setCell & setRow methods, as shown below.

Code Block:


  

 

  queryCellInfo(args) {

    let sheet = this.spreadsheetObj.getActiveSheet();

    if (args.colIndex == 1) {

      // apply format for 1st column

      setCell(

        args.rowIndex,

        args.colIndex,

        sheet,

        {

          format: '0.00E+00',

          style: {

            borderBottom: '1px solid #000000',

            borderLeft: '1px solid #000000',

            borderRight: '1px solid #000000',

            borderTop: '1px solid #000000',

            backgroundColor: 'yellow',

          },

        },

        true

      );

      // apply width for 1st column

      if (

        !sheet.columns[args.colIndex] ||

        sheet.columns[args.colIndex].height != 120

      ) {

        //Condition to skip already applied columns.

        setColumn(sheet, args.colIndex, { width: 120, customWidth: true });

      }

    }

  }


We have prepared the below sample based on our suggestions.


Sample Link:  https://stackblitz.com/edit/angular-8ysbbu-ae6qxn?file=app.component.ts


For more details, you can refer to the below link.


https://www.syncfusion.com/kb/13185/how-to-apply-cell-formats-and-number-formats-globally-in-spreadsheet


Loader.
Live Chat Icon For mobile
Up arrow icon