I have a grid which works great for a demo, but I need to get the XLS as a blob value in JavaScript so I can manipulate it.
This all works...
grid.toolbarClick = function(args) {
if (args['item'].id === 'Grid_excelexport') {
grid.excelExport(null, null, null, true);
}
}
but this syntax doesn't seem to be correct...
grid.excelExportComplete (args) {
// open blob in new window
}
Can you please assist?
Hi Andy,
Greetings from Syncfusion support.
We can get the Blob data from the excel exporting using excelExportComplete event. In below code example, We have pass the true value in the excelExport method in the toolbarClick event then it will be return the blob data in the excelExportComplete event. Please refer the below code example and sample for more information.
|
grid.toolbarClick = (args) => { if (args.item.id === 'Grid_excelexport') { grid.excelExport(null, false, null, true); } }; grid.excelExportComplete = (args) => { args.promise.then((e) => { console.log(e.blobData); }); };
|
Sample link: https://stackblitz.com/edit/wffbzj?file=index.ts,index.html
Help
Documentation: https://ej2.syncfusion.com/javascript/documentation/api/grid/#excelexport
https://ej2.syncfusion.com/javascript/documentation/api/grid/#excelexportcomplete
Please get back to us if you need further assistance.
Regards,
Joseph I
This worked for me - but when I duplicated for pdf, I get an error
Unhandled rejection (<[object Object]>, no stack trace)
grid.toolbarClick = function(args) {
if (args['item'].id === 'Grid_excelexport') {
grid.excelExport(null, null, null, true);
}
if (args['item'].id === 'Grid_pdfexport') {
grid.pdfExport(null, null, null, true);
}
if (args['item'].id === 'Grid_csvexport') {
grid.csvExport(null, null, null, true);
}
}
grid.pdfExportComplete = (args) => {
args.promise.then((e) => {
// console.log(e.blobData);
var reader = new FileReader();
reader.readAsDataURL(e.blobData);
reader.onloadend = function() {
var base64data = reader.result;
// console.log(base64data);
FileMaker.PerformScriptWithOption ( 'fnc - Export Report PDF ( param )', base64data, 5 );
}
});
};
Hi Andy,
Thanks for your update.
We can get the Blob data from the PDF exporting using pdfExportComplete event. In below code example, We have pass the true value in the pdfExport method in the toolbarClick event then it will be return the blob data in the pdfExportComplete event. Please refer the below code example and sample for more information.
|
grid.toolbarClick = function (args) { if (args.item.id === 'Grid_pdfexport') { grid.pdfExport(null, false, null, true); // We can get the Blob data in the pdfExportComplete event while pass true value in the pdfExport method } };
grid.pdfExportComplete = function (args) { args.promise.then((e) => { console.log(e.blobData); }); };
|
Sample link: https://stackblitz.com/edit/dmlvdr?file=index.js
Help Documentation: https://ej2.syncfusion.com/javascript/documentation/api/grid/#pdfexportcomplete
https://ej2.syncfusion.com/javascript/documentation/api/grid/pdfExportCompleteArgs/
Please get back to us if you need further assistance.
Regards,
Rajapandiyan S