Skip to content

Commit

Permalink
chore: remove JSZip references & add CSP rules for Web Workers
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Feb 11, 2024
1 parent 0e647ce commit 29a133e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 11 additions & 1 deletion packages/excel-export/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ Simple Export to Excel Service that allows to exporting as `.xls` or `.xlsx`.
- [@slickgrid-universal/utils](https://github.com/ghiscoding/slickgrid-universal/tree/master/packages/utils)

### External Dependencies
This package requires [excel-builder-vanilla](https://www.npmjs.com/package/excel-builder-vanilla) which itself requires [fflate](https://www.npmjs.com/package/fflate).
This package requires [excel-builder-vanilla](https://www.npmjs.com/package/excel-builder-vanilla) which itself also has a single dependency [fflate](https://www.npmjs.com/package/fflate) to compress the data before sending it to the browser.

### Installation
Follow the instruction provided in the main [README](https://github.com/ghiscoding/slickgrid-universal#installation), you can see a demo by looking at the [GitHub Demo](https://ghiscoding.github.io/slickgrid-universal/#/example02) page and click on "Export to Excel" from the Context Menu or the Grid Menu (aka hamburger menu).

You can also use nearly all Excel-Builder-Vanilla options, see their [Excel-Builder-Vanilla - Documentation](https://ghiscoding.gitbook.io/excel-builder-vanilla/) and also take a look at Slickgrid-Universal [Excel Export - Documentation](https://ghiscoding.gitbook.io/slickgrid-universal/grid-functionalities/export-to-excel) on how to use both.

### Usage
In order to use the Service, you will need to register it in your grid options via the `registerExternalResources` as shown below.

Expand Down Expand Up @@ -70,3 +72,11 @@ export class MyExample {
}
}
```

### CSP (Content Security Policy)
Please note that this Excel Export service is using `fflate` (it compresses the data before sending it to the browser) and for better performance it uses Web Workers and for that reason you might need to adjust your CSP rules. You simply need to add a CSP rule to avoid the error `worker-src 'self' blob:;`

```html
<meta http-equiv="Content-Security-Policy"
content="default-src 'self'; ...other rules... worker-src 'self' blob:;" />
```
7 changes: 1 addition & 6 deletions packages/excel-export/tsconfig.bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
"../typings",
"./node_modules/@types",
"../../node_modules/@types"
],
"paths": {
"jszip": [
"node_modules/jszip/dist/jszip.min.js"
]
}
]
},
"include": [
"../typings",
Expand Down
7 changes: 1 addition & 6 deletions packages/excel-export/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@
"src/typings",
"./node_modules/@types",
"../../node_modules/@types"
],
"paths": {
"jszip": [
"node_modules/jszip/dist/jszip.min.js"
]
}
]
},
"exclude": [
"dist",
Expand Down

0 comments on commit 29a133e

Please sign in to comment.