Hello,
I'm trying when exporting a Grid to excel file to format some columns raw content into hyperlink text.
here is the implementation of my excelExport function:
01.
function
excelExport(e) {
02.
if
(!exportFlag) {
03.
e.sender.showColumn(3);
04.
e.sender.showColumn(4);
05.
e.sender.showColumn(5);
06.
exportFlag =
true
;
07.
08.
var
sheet = e.workbook.sheets[0];
09.
var
data =
this
.dataSource.view();
10.
11.
for
(
var
i = 0; i < data.length; i++) {
12.
sheet.rows[i + 1].cells[3].formula =
"=HYPERLINK("
+ data[i].LinkExportPdf +
", Export Pdf "
+ data[i].Id +
")"
;
13.
sheet.rows[i + 1].cells[4].formula =
"=HYPERLINK("
+ data[i].LinkExportPpt +
", Export Ppt "
+ data[i].Id +
")"
;
14.
}
15.
e.preventDefault();
16.
17.
setTimeout(
function
() {
18.
e.sender.saveAsExcel();
19.
});
20.
}
else
{
21.
e.sender.hideColumn(3);
22.
e.sender.hideColumn(4);
23.
e.sender.hideColumn(5);
24.
exportFlag =
false
;
25.
}
26.
}
What i tried to do first is to assign direct the value by changing the cell value which doesn't provide any result, 2nd problem, when debugging the columns 3, 4 and 5 aren't into my sheet object even with the showColumn and when downloading the excel file, like any of the operation above isn't take in consideration.
My Grid set Events like this:
1.
.Events(e =>
2.
{
3.
e.DataBound(
"dataBound"
);
4.
e.ExcelExport(
"excelExport"
);
5.
})
The excel setting is like this:
1.
.Excel(excel => excel
2.
.FileName(
"ExcelFileName.xlsx"
)
3.
.AllPages(
false
)
4.
.ProxyURL(Url.Action(
"BackOfficeExportFunction"
,
"Grid"
))
5.
)
Thanks in advance for your help !