In my Angular 2 project utilizing Wijmo version 5.20172.359 with Angular 4.4.4 and TypeScript 2.5.3, I have successfully implemented components like FlexGrid, FlexPie, and FlexCharts. However, when attempting to integrate the Excel Import functionality using the included ExcelImportExport project from the TS/Angular2 Samples provided with the build, I encounter an error during the build process:
Uncaught TypeError: window.require is not a function
at Object../node_modules/wijmo/wijmo.xlsx.js (app.js:86218)
at __webpack_require__ (app.js:678)
at fn (wijmo.grid.xlsx.js:13)
at Object../node_modules/wijmo/wijmo.grid.xlsx.js (app.js:86158)
at __webpack_require__ (app.js:678)
at fn (wijmo.grid.xlsx.js:13)
at Object../app/home/components/import-grid/import-grid.component.ts (app.js:12533)
at __webpack_require__ (app.js:678)
at fn (wijmo.grid.xlsx.js:13)
at Object../app/home/home.module.ts (app.js:19226)
The component includes the following imports:
import * as JSZip from 'jszip';
import * as wjcGrid from 'wijmo/wijmo.grid';
import * as wjcCore from 'wijmo/wijmo';
import * as wjcXlsx from 'wijmo/wijmo.xlsx';
import * as wjcGridXlsx from 'wijmo/wijmo.grid.xlsx';
import { WjGridModule } from 'wijmo/wijmo.angular2.grid';
If I remove the import for wjcGridXlsx, the issue disappears. However, this import is necessary for the Excel import feature, pinpointing where the problem lies.
I am uncertain of how to resolve this issue.
The wijmo.xlsx module appears to wrap https://github.com/SheetJS/js-xlsx, and while I have encountered some references to errors related to its implementation, I have not found a solution yet.
Note that I am using webpack instead of Angular CLI.