Skip to content

Replies

0
Alexis Michaelides
Alexis Michaelides answered on Aug 3, 2017 7:34 PM

Managed to fix this myself after a bit of R&D. Posting complete code below (please excuse formatting)

function exportSecondGrid(workbook) {

var headerArr = [];
$.ig.GridExcelExporter.exportGrid($("#grid1"), {
fileName: "igGrid",
worksheetName: "Sheet2"
},
{
headerCellExporting: function(sender, args) {
// We will save all the headers coming to our array for retrieval later on
headerArr.push(args.headerText);
if (args.columnIndex === 0) {
sender._workbook = workbook;
sender._workbook.worksheets().add( sender._worksheet.name());
sender._worksheet = sender._workbook.worksheets(1);
}
},
exportEnding: function(sender, args) {
// Now use the array of headers to be updated
var row = sender._worksheet.rows(0);
for(var ind=0; ind < headerArr.length; ind++) {
row.setCellValue(ind, headerArr[ind]);
}

}
}
);

}

Use this with the original first function and everything will be perfect

0
Alexis Michaelides
Alexis Michaelides answered on Aug 3, 2017 12:29 PM

How would I know the header values to be inserted here. In sample we are using the hardcoded text but in real we need it to come via grid's own data.

Please post the complete sample