I used ignite 15.2 and I found javascript to help to client export grid data to excel file:https://www.igniteui.com/help/using-the-javascript-excel-library?v=15.2It's still working good.
But after upgrade to ignite v16.1, I got error "Invalid arguments" when run export, cause that :
workbook.save(function (err, data) { if (err) { alert('Error Exporting'); } else { var blob = new Blob([data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }); saveAs(blob, "grid.xlsx"); } });
Only 1 argument(is a function) pass in save method, but in infragistics.excel.js(v16.1) has checking the number of argument:
save: function() { var n; if (arguments.length === 2) { n = 1 } else if (arguments.length === 3) { n = 0 } switch (n) { case 0: return this._save.apply(this, arguments); case 1: return this._save1.apply(this, arguments); default: throw new Error("Invalid arguments") } } ....
we can see n alway have value = undefined and we will get "Invalid arguments" errorHow should I fix it?
https://www.igniteui.com/help/using-the-javascript-excel-library?v=16.1 (same code with v15.2)
Sorry for my poor english skill.
Hello Quan,
We apologize that our help document has not been updated, but ig.excel.Workbook’s save() method(v.16.1) actually accepts only two or three arguments as illustrated in the API document below. Single argument is not valid here.
ig.excel.Workbook - Save methodhttp://jp.igniteui.com/help/api/2016.1/ig.excel.Workbook#methods:save
As you can see in the above document, the valid argument will be saveOptions(optional), successCallback, and failCallback.So you should be able to save a workbook as follows.
-------------------- workbook.save({ type: 'blob' }, function (data) { saveAs(data, "grid.xlsx"); }, function (error) { } );--------------------
I have attached the sample html for you.In this sample, you can save an Excel file by clicking the button on the page.
Please let me know if I may be of further assistance.
Thank you,Mihoko Kamiishi