Hi Sandi,
Greetings
from Syncfusion support
Query#: Is
there a way to apply the "Wrap Text" control to cells when exporting
a Grid to Excel?
You can wrap
the text when exporting a Grid to Excel by using the excelQueryCellInfo
event of Grid. By using this excelQueryCellInfo event, we have defined
the wrapText style property as true then
text content will wrap to the next line.
For your
convenience we have attached a sample below to demonstrate the setup we used.
Please refer the below code example and sample for more information.
|
App.js
function excelQueryCellInfo(args) {
//excelQueryCellInfo event of Grid
args.style = { wrapText:true };
//here we can set the wrapText as true in the
style property
}
return (
<div>
<GridComponent id='Grid' dataSource={inventoryData} height={315} allowPaging={true} toolbar={toolbar} allowExcelExport={true} toolbarClick={toolbarClick}
ref={g => grid = g} excelQueryCellInfo={excelQueryCellInfo}>
<ColumnsDirective>
. . . . . . . . .
. . .
. . . . . . . . .
. . .
. . . . . . . . .
. . .
</ColumnsDirective>
<Inject services={[Toolbar, Page, ExcelExport]}/>
</GridComponent></div>)
}
|
Sample: https://stackblitz.com/edit/react-cfr9uezb-uizpjhft?file=App.js
API: https://ej2.syncfusion.com/react/documentation/api/grid/#excelquerycellinfo
https://ej2.syncfusion.com/react/documentation/api/grid/excelQueryCellInfoEventArgs/#style
https://ej2.syncfusion.com/react/documentation/api/grid/excelStyle/#wraptext
Regards,
Rajapandi R