Web Workers and Flexsheet

Posted by: curiosichi on 26 August 2019, 7:14 pm EST

  • Posted 26 August 2019, 7:14 pm EST

    In Angular 8, web workers are now easily integrated into the app via CLI. However when trying to utilize the power of web workers with flexsheet, it doesn’t work.

    https://www.grapecity.com/wijmo/demos/Grid/ImportExportPrint/PDF/WebWorkers/angular

    The example of PDF export with webworkers is not downloadable, so I wasn’t able to see how it works in the IDE, but recreating it in Angular 8 by just copying component code over it was not compiling due to the limitations of Web Workers not being able to access DOM (or what I believe are flexsheet’s class access to DOM elements).

    Is there any way I could see an example with flexsheet and web workers in Angular 8?

  • Posted 27 August 2019, 7:02 am EST

    Hi,

    Please refer to the sample attached that demonstrates the desired behavior.

    Regards,

    Ashwin

    FlexSheet_ExportPDFWebWorkers.zip

  • Posted 27 August 2019, 6:35 pm EST

    The example provided was Angular 7 and uses pure JS loader and xmldom. In Angular 8, web workers are now integrated into the app differently with file names ending in *.worker.ts

    https://angular.io/guide/web-worker

    I’d like to know if this example could be updated to an Angular 8 typescript type of implementation.

    I was also a bit confused as to why there is another addEventListener in the loadWorker() function of the component, when addEventListener() is defined in the JS webworker.

    Lastly, is there any functional way to get web workers to be used to do complex Flexsheet computations or custom functions. I am unable to include the flexsheet class on a webworker’s import, but perhaps there is a webworker friendly version available? Some of the custom functions we trigger within flexsheet take a while to process and lock the UI thread (causing latency when moving between grid cells). I would like to offload this processing to a web worker and then update the grid with the calculated result.

    import { FlexSheet, SheetCollection } from 'wijmo/wijmo.grid.sheet';
    
  • Posted 29 August 2019, 6:51 am EST

    Hi,

    Regarding web workers:

    We have asked the dev team to look into this issue. The internal tracking id of the case if 396026. We will give you an update as soon as we hear from them.

    Regarding message event listener:

    The event listener that was added in the worker file was to import the JS file from the url that was sent from the component.

    The event listener in the component was added to so that we can start exporting the FlexSheet when the JS file is loaded in the worker.

    Regarding FlexSheet formulas:

    We are working on this case. We will give you an update as soon as possible.

    ~regards

  • Posted 30 August 2019, 12:44 am EST

    Hi,

    Regarding using web workers to calculate formulas:

    We are sorry but you cannot use web workers for calculation inside the FlexSheet, But, you can perform the complex calculations outside the FlexSheet and then show the result in the control. Refer to the sample attached for a demonstration.

    ~regards

    FlexSheet_WebWorker.zip

Need extra support?

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

Learn More

Forum Channels