Excelio - Incorrect file format when outside of a Web Worker

Posted by: mathieu.bilodeau-roy on 29 January 2021, 6:41 pm EST

    • Post Options:
    • Link

    Posted 29 January 2021, 6:41 pm EST

    Hi,

    We’ve been using Excel IO to load excel files into SpreadJs. (Angular App)

    It’s currently working through a webworker task and everything is going smoothly.

    We would like to remove this webworker, but we noticed that, somehow, when using excelio’s open method outside of the webworker always results in a “ErrorCode: 1” with message “Incorrect File Format”.

    I am a bit confused, as the same file is correctly read when in a webworker context.

    Is there anything inside the Angular context that could make it so the filereader of excelio may not work the same way as in the context of a webworker?

    Thank you,

    Mathieu

  • Posted 30 January 2021, 5:33 pm EST

    To anyone finding this later on, the issue was that following Angular 6, some librairies like SignalR have issues by not finding Buffer, global and Process.

    A common workaround is adding to your index.html

    var global = global || window;

    var Buffer = Buffer || ;

    var process = process || {

    env: { DEBUG: undefined },

    version:

    };

    The buffer line here seems to break ExcelIO. I removed it and instead added

    (window as any).Buffer = (window as any).Buffer || require(‘buffer’).Buffer;

    in polyfills.ts.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels