Posted 20 April 2023, 3:09 pm EST
How to apply a color opacity in foreColor and backColor method?
Forums Home / Spread / SpreadJS
Posted by: pedro.moraes on 20 April 2023, 3:09 pm EST
Posted 20 April 2023, 3:09 pm EST
How to apply a color opacity in foreColor and backColor method?
Posted 23 April 2023, 3:59 pm EST
Hello Pedro,
You can use rgba() function in the foreColor and backColor property of the Style object to set color with opacity. Also, you can use hex values as well.
Please refer to the code snippet and attached sample.
sheet.setValue(1, 0, 'hello world');
sheet.setValue(1, 1, 'hello world');
sheet.getCell(0, 0).backColor('rgba(255, 0, 0, 1)');
sheet.getCell(0, 1).backColor('rgba(255, 0, 0, 0.6)');
sheet.getCell(0, 1).backColor('rgba(255, 0, 0, 0.3)');
sheet.getCell(1, 0).foreColor('rgba(0, 0, 255, 1)');
sheet.getCell(1, 1).foreColor('rgba(0, 0, 255, 0.6)');
sheet.getCell(1, 1).foreColor('rgba(0, 0, 255, 0.3)');
Please let us know if you still face any issues.
Doc references:
Style.foreColor:https://www.grapecity.com/spreadjs/api/classes/GC.Spread.Sheets.Style#forecolor
Style.backColor: https://www.grapecity.com/spreadjs/api/classes/GC.Spread.Sheets.Style#backcolor
Regards,
Ankit