When extracting excel, the problem of changing the font color.

hi.

When exporting to Excel, there is a problem of defining the font color.

//Solution from SYncfusion answers found through googling



=> a problem that has arisen


The format 'ColorTranslator' exists in both 'system.drawing.Commom' and ' system.drawing.Primitives'.


//The method that I applied.

sheet.Range[iRow, i + 11].CellStyle.Font.RGBColor = Color.FromArgb(255, 0, 0);



Both methods apply cellstyle, but the problem with Font color is not solved.


Is there a way?


regards.


1 Reply

RR Rajapandi Ravi Syncfusion Team January 9, 2023 01:16 PM UTC

Hi TaeWook,


Greetings from Syncfusion support


By using excelQueryCellInfo event, you can customize the style of particular cell while exporting the Grid. Based on your query we have prepared a sample and we suggest you use the below way to achieve your requirement. Please refer the below code example, sample and documentation for more information.


 

<script>

    function toolbarClick(args) { //toolbarClick event of Grid

        var gridObj = document.getElementById("Grid").ej2_instances[0];

        if (args.item.text === 'Excel Export') {

            gridObj.excelExport();

        }

    }

 

    function excelQueryCellInfo(args) { //excelQueryCellInfo event of Grid

        if (args.column.field == 'EmployeeID') {

            args.style = { fontColor: '#ff0000' };

        }

   }

</script>

 


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/sample1432535164.zip


ExcelStyle: https://ej2.syncfusion.com/javascript/documentation/api/grid/excelStyle/


Documenation: https://ej2.syncfusion.com/aspnetcore/documentation/grid/excel-export/excel-cell-style-customization#conditional-cell-formatting


Regards,

Rajapandi R



Loader.
Up arrow icon