Set the string column in Excel export to "Text" format

hi

When we use excel export, The column type is string get returned in the xlsx as "General".
We want to achieve to show the actual formatted (treated as text value in excel) in the xlsx File.
How do we achieve this?
Thank you

QQ20250103-015650.jpg

2 Replies

LI lixin January 6, 2025 02:55 AM UTC

Add [format: '@ @'] to the column attribute




DM Dineshnarasimman Muthu Syncfusion Team January 6, 2025 03:56 PM UTC

Hi lixin,


Greetings from Syncfusion Support.


Upon reviewing your query, it appears that you need to export string-type column values as text in an XLSX file. As mentioned in your earlier update, we recommend setting the numberFormat property to '@' in the excelQueryCellInfo event of the grid.


The code snippet of the implementation and sample have been attached for your reference.


function excelQueryCellInfo(args) {

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

    args.style = { numberFormat: '@' };

  }

}

 


Sample: https://stackblitz.com/edit/efb5gpcr?file=index.js


Image:

 



Please get back to for further assistance.


Regards,

Dineshnarasimman M



Loader.
Up arrow icon