ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: hdl on March 08, 2022, 09:19:44 am
-
How do I import Excel files returned from asp.net webapi ?
Suppose I have a WebApi to download files.
like: http://localhost/api/download?fileid=111
-
It's done with help of pq.excel.importXl and grid.importWb methods:
https://paramquery.com/pro/api#method-importXl
https://paramquery.com/pro/api#method-importWb
//import xlsx file from remote location.
pq.excel.importXl( {url: 'http://localhost/api/download?fileid=111'}, function( wb ){
grid.importWb({ workbook: wb, extraRows: 10, extraCols: 10 });
grid.hideLoading();
})
-
I tried. But an exception is thrown.
Uncaught TypeError: Cannot read properties of undefined (reading 'uint8array')
at Object.c.transformTo (jszip.min.js:12:23187)
at c.prepareReader (jszip.min.js:12:27706)
at c.load (jszip.min.js:12:27806)
at new c (jszip.min.js:12:24114)
at c.b.exports [as load] (jszip.min.js:12:8048)
at new c (jszip.min.js:12:7348)
at Object.getWorkBook (pqgrid.min.js:17:7374)
at l (pqgrid.min.js:17:9437)
at Object.Import (pqgrid.min.js:17:9675)
at Object.importXl (pqgrid.min.js:18:2317)
-
That means something is wrong in the webAPI. Please check the output when you open the webAPI url directly in browser: http://localhost/api/download?fileid=111
It's supposed to download a file similar to this: http://paramquery.com/pro2/Content/workbook.xlsx