You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Team,
I am trying to use the sheetjs for making the excel download from client side. The download is working fine in chrome and firefox. But, when trying to run the download from Safari (Ipad pro 12.8) it is giving error like "Safari can not open the page. The error was the operation can not be completed. The error was "Webkitblob resource error 1". I was intially using the code
function s2ab(s) {
const buf = new ArrayBuffer(s.length);
const view = new Uint8Array(buf);
for (let i = 0; i !== s.length; ++i) {
view[i] = s.charCodeAt(i) & 0xff;
}
return buf;
}
// This function is used for crerating the excel sheet based of the data array and excel name. This is the using the sheetJs(xlsx) npm module
const exportToExcel = (data, ExcelName) => {
import('xlsx').then(XLSX => {
const wb = new Workbook();
const ws = XLSX.utils.json_to_sheet(data);
wb.SheetNames.push('sheet');
wb.Sheets['sheet'] = ws;
const wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: true, type: 'binary'});
const url = window.URL.createObjectURL(new Blob([s2ab(wbout)], {type: 'application/octet-stream'}));
download(url, ${ExcelName}.xlsx);
});
};
export default exportToExcel;`.
Hi Team,
I am trying to use the sheetjs for making the excel download from client side. The download is working fine in chrome and firefox. But, when trying to run the download from Safari (Ipad pro 12.8) it is giving error like "Safari can not open the page. The error was the operation can not be completed. The error was "Webkitblob resource error 1". I was intially using the code
`function Workbook() {
if (!(this instanceof Workbook)) {
return new Workbook();
} else {
this.SheetNames = [];
this.Sheets = {};
return true;
}
}
export const download = (url, name) => {
const a = document.createElement('a');
a.href = url;
a.download = name;
a.click();
window.URL.revokeObjectURL(url);
};
function s2ab(s) {
const buf = new ArrayBuffer(s.length);
const view = new Uint8Array(buf);
for (let i = 0; i !== s.length; ++i) {
view[i] = s.charCodeAt(i) & 0xff;
}
return buf;
}
// This function is used for crerating the excel sheet based of the data array and excel name. This is the using the sheetJs(xlsx) npm module
const exportToExcel = (data, ExcelName) => {
import('xlsx').then(XLSX => {
const wb = new Workbook();
const ws = XLSX.utils.json_to_sheet(data);
wb.SheetNames.push('sheet');
wb.Sheets['sheet'] = ws;
const wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: true, type: 'binary'});
const url = window.URL.createObjectURL(new Blob([s2ab(wbout)], {type: 'application/octet-stream'}));
download(url,
${ExcelName}.xlsx
);});
};
export default exportToExcel;`.
Then as mentioned in the post https://stackoverflow.com/questions/54339607/mobile-safari-download-issue-the-operation-couldn-t-be-completed-webkitblobr i tried to include a timeout for the revokeObjectURL.
export const download = (url, name) => { const a = document.createElement('a'); a.href = url; a.download = name; a.click(); setTimeout(() => { window.URL.revokeObjectURL(url); }, 1000); };
But, now getting the file as "Unknown". Can you please suggest the safari is currently supported and how the download issue can be fixed?
The text was updated successfully, but these errors were encountered: