title: Angular 7 : xlsx_styles__WEBPACK_IMPORTED_MODULE_2__.utils.json_to_sheet is not a function
body: <p>Before i try to export excel using xlxs-styles, after i npm install and ng serve, i got error :</p>
  
  <pre><code>WARNING in ./node_modules/xlsx-styles/xlsx.js
  Module not found: Error: Can't resolve 'crypto' in 'C:\Users\hansen\Documents\asg_tax_webclient\node_modules\xlsx-styles'
  
  ERROR in ./node_modules/xlsx-styles/dist/cpexcel.js
  Module not found: Error: Can't resolve './cptable' in 'xxx\node_modules\xlsx-styles\dist'
  ERROR in ./node_modules/xlsx-styles/xlsx.js
  Module not found: Error: Can't resolve 'fs' in 'xxx\node_modules\xlsx-styles'
  ERROR in ./node_modules/xlsx-styles/ods.js
  Module not found: Error: Can't resolve 'fs' in 'xxx\node_modules\xlsx-styles'
  </code></pre>
  
  <p>So i try to found the solution and i found then i tried the solution in here
  <a href="https://github.com/SheetJS/js-xlsx/issues/285" rel="nofollow noreferrer">https://github.com/SheetJS/js-xlsx/issues/285</a>,</p>
  
  <p>Base on that solution, I create a webpack with tutorial from this source : <a href="http://opensourceforgeeks.blogspot.com/2018/12/how-to-customize-build-configuration.html" rel="nofollow noreferrer">http://opensourceforgeeks.blogspot.com/2018/12/how-to-customize-build-configuration.html</a> : </p>
  
  <pre><code>module.exports = {
      module: {
        rules: [
           {
          //   test: /\.example$/,
          //   use: ["example-loader"],
          //   include: path.resolve(__dirname, "./")
  
  
          },
          //test on angular.json
          {
            "options": {
              "scripts": [
                "node_modules/chart.js/dist/Chart.min.js"
              ],
              "styles": [
                {
                  "input": "node_modules/@progress/kendo-theme-default/dist/all.css"
                },
                "node_modules/flag-icon-css/css/flag-icon.css",
                "node_modules/font-awesome/css/font-awesome.css",
                "node_modules/simple-line-icons/css/simple-line-icons.css",
                "src/scss/style.scss",
                "node_modules/ngx-toastr/toastr.css"
              ],
            }
          },
        ]
      },
      node: {
          fs: 'empty'
      },
      externals: [
        {
          './cptable': 'var cptable',
        }
      ],
  
    };
  </code></pre>
  
  <p>After that, everything is ok when i ng serve.</p>
  
  <p>But when i try to export data to excel, i got error again in console:</p>
  
  <pre><code>ERROR TypeError: xlsx_styles__WEBPACK_IMPORTED_MODULE_2__.utils.json_to_sheet is not a function
      at 
  </code></pre>
  
  <p>Here is my import code and method to write excel:</p>
  
  <pre><code>import {WorkSheet as XLSXWorkSheet, utils as XLSXUtils, WorkBook as XLSXWorkBook, write as StyleWrite, utils as StyleUtils, CellObject as StyleCellObject} from 'xlsx-styles';
  import {ExcelConfig} from "../constants/excel.config";
  import {DOCUMENT} from '@angular/common';
  import * as FileSaver from 'file-saver';
  import * as XLSX from 'xlsx';
  
  public exportAsExcelFileWithStyle(json: any[], excelFileName: string): void {
      console.log(json,excelFileName);
      this.worksheet = XLSXUtils.json_to_sheet(json, {header: [], skipHeader:true});
  
      const workbook: XLSXWorkBook = { Sheets: { 'data': this.worksheet }, SheetNames: ['data'] };
      const excelBuffer: any =  StyleWrite(workbook,
        { bookType: 'xlsx', type: 'buffer', cellDates: true, cellStyles: true});
  
      this.openExcelFile(excelBuffer, excelFileName);
  
      //this.saveAsExcelFile(excelBuffer, excelFileName);
    }
  </code></pre>
  
  <p>Am I forgot something? I would be glad for any help.</p>