stephen-hardy / xlsx.js

XLSX.js is a JavaScript library for converting the data in base64 XLSX files into JavaScript objects - and back! Please note that this library is licensed under the Microsoft Office Extensible File License - a license NOT approved by the OSI. While this license is based off of the MS-PL, which is OSI-approved, there are significant differences.
http://blog.innovatejs.com/?tag=xlsx-js
Other
575 stars 122 forks source link

Internet explorer: The data area passed to a system call is too small. #36

Open LeachBogdan opened 10 years ago

LeachBogdan commented 10 years ago

I get this error when trying to set window.location to result.href() but only in IE. Everything works fine in Chrome or Firefox.

var data_arr = factory.prepareData(data, coldefs);
var sheet = {
    creator: userCredentials.Name,
    lastModifiedBy: userCredentials.Name,
    worksheets: [
        {
        data: data_arr,
        table: true,
        name: name
        }
    ]
};

window.location = xlsx(sheet).href(); 

is how i'm creating the sheet.

gbelmm commented 10 years ago

+1 please

nirajkrz commented 9 years ago

i am also facing the same problem (Only In IE). Did you find any workaround for this?

LeachBogdan commented 9 years ago

I've worked around the problem by getting the base64 and turning it into a blob using this function:

    factory.b64toBlob = function (b64Data, contentType, sliceSize) {
        contentType = contentType || '';
        sliceSize = sliceSize || 512;

        var byteCharacters = atob(b64Data);
        var byteArrays = [];

        for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
            var slice = byteCharacters.slice(offset, offset + sliceSize);

            var byteNumbers = new Array(slice.length);
            for (var i = 0; i < slice.length; i++) {
                byteNumbers[i] = slice.charCodeAt(i);
            }

            var byteArray = new Uint8Array(byteNumbers);

            byteArrays.push(byteArray);
        }

        var blob = new Blob(byteArrays, {type: contentType});
        return blob;
    };

And then saving it using a FileSave script.