@libregrid/excel-export 1.3.1 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -27
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,44 +1,53 @@
|
|
|
1
1
|
# @libregrid/excel-export
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Export grid data as Excel `.xlsx` workbooks in the browser. Configure styles,
|
|
4
|
+
worksheet names, grouped-row outlines, and multiple sheets without an export
|
|
5
|
+
server.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
[Documentation and examples](https://libregrid.dev/excel-export)
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npm install ag-grid-community @libregrid/excel-export
|
|
12
|
+
npm install "ag-grid-community@^36.1.0" @libregrid/excel-export
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Requires `ag-grid-community >=36.1.0 <37` as a peer dependency.
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
+
In a browser TypeScript project, add a grid container before running the code:
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<button id="export">Export to Excel</button>
|
|
23
|
+
<div id="grid" style="height: 400px"></div>
|
|
24
|
+
```
|
|
25
|
+
|
|
19
26
|
```ts
|
|
20
27
|
import { ModuleRegistry, AllCommunityModule, createGrid } from 'ag-grid-community';
|
|
21
28
|
import { ExcelExportModule } from '@libregrid/excel-export';
|
|
22
29
|
|
|
23
30
|
ModuleRegistry.registerModules([AllCommunityModule, ExcelExportModule]);
|
|
24
31
|
|
|
25
|
-
const api = createGrid(document.querySelector('#grid')!, {
|
|
32
|
+
const api = createGrid(document.querySelector<HTMLElement>('#grid')!, {
|
|
26
33
|
columnDefs: [{ field: 'name' }, { field: 'value' }],
|
|
27
34
|
rowData: [{ name: 'Widget', value: 42 }],
|
|
28
35
|
});
|
|
29
36
|
|
|
30
|
-
|
|
37
|
+
document.querySelector('#export')!.addEventListener('click', () => {
|
|
38
|
+
api.exportDataAsExcel({ fileName: 'sales.xlsx', sheetName: 'Sales' });
|
|
39
|
+
});
|
|
31
40
|
```
|
|
32
41
|
|
|
33
42
|
## API
|
|
34
43
|
|
|
35
|
-
| Method
|
|
36
|
-
|
|
|
37
|
-
| `exportDataAsExcel(params?)`
|
|
38
|
-
| `getDataAsExcel(params?)`
|
|
39
|
-
| `getSheetDataForExcel(params?)`
|
|
40
|
-
| `exportMultipleSheetsAsExcel(params)` | Downloads several worksheets in one file.
|
|
41
|
-
| `getMultipleSheetsAsExcel(params)`
|
|
44
|
+
| Method | Purpose |
|
|
45
|
+
| ------------------------------------- | ------------------------------------------------------- |
|
|
46
|
+
| `exportDataAsExcel(params?)` | Downloads the grid data as an `.xlsx` file. |
|
|
47
|
+
| `getDataAsExcel(params?)` | Returns the `.xlsx` bytes as a Blob. |
|
|
48
|
+
| `getSheetDataForExcel(params?)` | Returns the data for one worksheet as an opaque string. |
|
|
49
|
+
| `exportMultipleSheetsAsExcel(params)` | Downloads several worksheets in one file. |
|
|
50
|
+
| `getMultipleSheetsAsExcel(params)` | Returns several worksheets in one Blob. |
|
|
42
51
|
|
|
43
52
|
Pass `ExcelExportParams` to control the file name, the sheet name, styling,
|
|
44
53
|
freeze panes, row-group outlines, page setup, and protection.
|
|
@@ -46,26 +55,38 @@ freeze panes, row-group outlines, page setup, and protection.
|
|
|
46
55
|
Date cells export as 1900-system serials and display with the built-in
|
|
47
56
|
`mm-dd-yy` format unless the cell's style sets a `numberFormat`.
|
|
48
57
|
|
|
49
|
-
##
|
|
50
|
-
|
|
51
|
-
Cell images (`addImageToCell`), Excel tables (`exportAsExcelTable`) and cell
|
|
52
|
-
notes are not included. The decisions are recorded in the
|
|
53
|
-
[gap list](https://github.com/libregrid/libregrid/blob/main/docs/parity/gap-list.md).
|
|
58
|
+
## Multiple worksheets
|
|
54
59
|
|
|
55
60
|
With `@libregrid/menu` also registered, the Export item (with CSV and Excel
|
|
56
61
|
entries) appears in the context menu. Exporting several sheets uses the data
|
|
57
|
-
strings from `getSheetDataForExcel
|
|
62
|
+
strings from `getSheetDataForExcel`. Register `ExcelExportModule` for both
|
|
63
|
+
grids and call this helper from an export button:
|
|
58
64
|
|
|
59
65
|
```ts
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
firstApi.
|
|
66
|
+
import type { GridApi } from 'ag-grid-community';
|
|
67
|
+
|
|
68
|
+
export function exportTwoGrids(firstApi: GridApi, secondApi: GridApi): void {
|
|
69
|
+
const sheets = [
|
|
70
|
+
firstApi.getSheetDataForExcel({ sheetName: 'First' }),
|
|
71
|
+
secondApi.getSheetDataForExcel({ sheetName: 'Second' }),
|
|
72
|
+
].filter((sheet): sheet is string => sheet !== undefined);
|
|
73
|
+
firstApi.exportMultipleSheetsAsExcel({ data: sheets, fileName: 'multi.xlsx' });
|
|
74
|
+
}
|
|
65
75
|
```
|
|
66
76
|
|
|
77
|
+
## Limitations
|
|
78
|
+
|
|
79
|
+
Cell images (`addImageToCell`), Excel tables (`exportAsExcelTable`), and cell
|
|
80
|
+
notes are not included. See the [gap list](https://github.com/libregrid/libregrid/blob/main/docs/parity/gap-list.md).
|
|
81
|
+
|
|
82
|
+
## Angular
|
|
83
|
+
|
|
84
|
+
Use the same column definitions and grid options with `ag-grid-angular`.
|
|
85
|
+
Register the modules shown above through `provideLibreGrid` from
|
|
86
|
+
[`@libregrid/angular`](../angular/README.md). See the
|
|
87
|
+
[Angular setup](https://libregrid.dev/angular) for a complete component and bootstrap example.
|
|
88
|
+
|
|
67
89
|
## License
|
|
68
90
|
|
|
69
|
-
MIT — see [LICENSE](./LICENSE). LibreGrid is an independent
|
|
91
|
+
MIT — see [LICENSE](./LICENSE) and [NOTICE](./NOTICE). LibreGrid is an independent
|
|
70
92
|
project and is not affiliated with, endorsed by, or sponsored by AG Grid Ltd.
|
|
71
|
-
See [NOTICE](./NOTICE) for third-party attribution.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libregrid/excel-export",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Excel (xlsx) export for AG Grid Community — part of LibreGrid",
|
|
5
5
|
"keywords": ["libregrid", "ag-grid", "data-grid", "excel", "xlsx", "export"],
|
|
6
6
|
"homepage": "https://github.com/libregrid/libregrid#readme",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"sideEffects": false,
|
|
16
16
|
"peerDependencies": { "ag-grid-community": ">=36.1.0 <37" },
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@libregrid/core": "^1.3.
|
|
19
|
-
"@libregrid/menu": "^1.3.
|
|
18
|
+
"@libregrid/core": "^1.3.4",
|
|
19
|
+
"@libregrid/menu": "^1.3.4",
|
|
20
20
|
"fflate": "^0.8.2"
|
|
21
21
|
},
|
|
22
22
|
"files": ["dist", "LICENSE", "NOTICE", "README.md"],
|