我已经使用syncfusion-ej2网格(https://ej2.syncfusion.com/16.1.32/angular/documentation/grid/)实现了一个出色的导出功能。网格中有一列包含URL。导出完成后,这些链接将在Excel表格上以HTML语法显示。我已经在互联网上搜索了此内容,但找不到任何解决方案。请告知。
答案 0 :(得分:1)
我们建议您使用Grid的“ excelQueryCellInfo”事件。在“ excelQueryCellInfo”事件处理函数中,我们删除了单元格数据中包含的定位标记,并仅将要导出的文本内容传递给excel。请参考下面的代码示例,
[html]
<ejs-grid #masterGrid [dataSource]='data' ... [allowExcelExport]='true' (excelQueryCellInfo)='excelQueryCellInfo($event)'>
...
</ejs-grid>
[ts]
excelQueryCellInfo(args:any):void{
if(args.column.field == "CustomerID"){ //Check for the “CustomerID” column which has the anchor data
let container:any = document.createElement("div");
container.innerHTML = args.value;
args.value = container.textContent; //Pass only the string content to be exported to excel
}
}
为方便起见,我们还准备了样品。请参考下面的链接, 样本:https://stackblitz.com/edit/angular-srzcxu-41noip?file=normal-edit.component.ts
文档:https://ej2.syncfusion.com/angular/documentation/grid/api-gridComponent.html#excelquerycellinfo
马杜 [Syncfusion小组]