angularexcelspreadjs

Incorrect file format error while importing spreadjs


I am getting invalid file format error while importing spreadjs

 loadSpreadSheet(assetFile: any) {
    let fileContent = assetFile.fileContent;
    const uint8Array = Uint8Array.from(atob(fileContent), c => c.charCodeAt(0));
    const blb = new Blob([uint8Array])
    const file = new File([blb], 'abc.xlsx', { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });

    if (!file) {
      return;
    }
    var options: any = this.getOptions('open');
    this.changedetector.detectChanges();
    this.spread.import(file, function () { console.log("succ") }, function (error) { console.log(error) }, { fileType: GC.Spread.Sheets.FileType.excel });
    this.changedetector.detectChanges();
  }

The same above code is working fine in my POC. But when I am integrating the same code in my Realtime application I am getting this below error enter image description here

Only different is, This code is available inside library which is binding in iFrame.


Solution

  • It's working now after adding worker-src 'self' blob:; in content security policy in meta data header.