@chartts/excel 0.1.3 → 0.1.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 +72 -0
- package/package.json +5 -4
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://www.npmjs.com/package/@chartts/excel"><img src="https://img.shields.io/npm/v/@chartts/excel?color=06B6D4&label=npm" alt="npm version" /></a>
|
|
3
|
+
<a href="https://github.com/chartts/chartts/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-06B6D4" alt="MIT License" /></a>
|
|
4
|
+
<a href="https://chartts.com"><img src="https://img.shields.io/badge/docs-chartts.com-06B6D4" alt="Documentation" /></a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# @chartts/excel
|
|
8
|
+
|
|
9
|
+
Excel adapter for Chartts. Import and export .xlsx spreadsheets as chart data.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @chartts/excel @chartts/core
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Uses [SheetJS](https://sheetjs.com/) for Excel parsing.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { fromExcel, toExcel } from "@chartts/excel"
|
|
23
|
+
|
|
24
|
+
// Read .xlsx file
|
|
25
|
+
const response = await fetch("/data/sales.xlsx")
|
|
26
|
+
const buffer = await response.arrayBuffer()
|
|
27
|
+
const data = fromExcel(buffer)
|
|
28
|
+
|
|
29
|
+
// Specific sheet and range
|
|
30
|
+
const data2 = fromExcel(buffer, {
|
|
31
|
+
sheet: "Q1 Report",
|
|
32
|
+
range: "A1:D10",
|
|
33
|
+
labelColumn: "Month",
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
// Export to .xlsx
|
|
37
|
+
const xlsx = toExcel(chart.data)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## API
|
|
41
|
+
|
|
42
|
+
### `fromExcel(buffer, options?)`
|
|
43
|
+
|
|
44
|
+
Parses an Excel file (`ArrayBuffer` or `Uint8Array`) into `ChartData`.
|
|
45
|
+
|
|
46
|
+
| Option | Type | Default | Description |
|
|
47
|
+
|--------|------|---------|-------------|
|
|
48
|
+
| `sheet` | `string \| number` | `0` | Sheet name or index |
|
|
49
|
+
| `headers` | `boolean` | `true` | First row contains column names |
|
|
50
|
+
| `range` | `string` | entire sheet | Cell range, e.g. `"A1:D10"` |
|
|
51
|
+
| `labelColumn` | `number \| string` | first non-numeric | Column to use as labels |
|
|
52
|
+
| `seriesColumns` | `(number \| string)[]` | all numeric | Columns to use as series |
|
|
53
|
+
|
|
54
|
+
### `toExcel(data, options?)`
|
|
55
|
+
|
|
56
|
+
Converts `ChartData` to an `ArrayBuffer` (.xlsx format).
|
|
57
|
+
|
|
58
|
+
| Option | Type | Default | Description |
|
|
59
|
+
|--------|------|---------|-------------|
|
|
60
|
+
| `sheetName` | `string` | `"Sheet1"` | Name of the worksheet |
|
|
61
|
+
|
|
62
|
+
## Part of Chartts
|
|
63
|
+
|
|
64
|
+
Beautiful charts. Tiny bundle. Every framework.
|
|
65
|
+
|
|
66
|
+
- [Documentation](https://chartts.com/docs)
|
|
67
|
+
- [GitHub](https://github.com/chartts/chartts)
|
|
68
|
+
- [All packages](https://www.npmjs.com/org/chartts)
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chartts/excel",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Excel
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Excel adapter for Chartts. Import and export .xlsx spreadsheets as chart data.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
|
-
"dist"
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
18
19
|
],
|
|
19
20
|
"sideEffects": false,
|
|
20
21
|
"peerDependencies": {
|
|
21
|
-
"@chartts/core": "0.1.
|
|
22
|
+
"@chartts/core": "0.1.4"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
|