style-xlsx-m 0.1.7 → 0.1.9

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.
Files changed (2) hide show
  1. package/README.md +126 -8
  2. package/package.json +5 -4
package/README.md CHANGED
@@ -2,14 +2,8 @@
2
2
 
3
3
  ## ℹ️ About
4
4
 
5
- SheetJS and with Style! Get and Export Excel with basic styling options using JavaScript. But only get in xlsx and xlsm format. (this is now a beta version)
5
+ Style-xlsx-m is a custom [XLSX](https://www.npmjs.com/package/xlsx) (SheetJs) version library with styling from [xlsx-js-style](https://www.npmjs.com/package/xlsx-js-style)
6
6
 
7
- <p align="center">
8
- <a href="https://github.com/gitbrent/xlsx-js-style/">
9
- <img alt="xlsx-js-style sheetjs styles" title="style-xlsx-m sheetjs styles" src="https://github.com/gitbrent/xlsx-js-style/blob/7664a045cd8f96b6b1b92ad563babebb8d6e0b4a/demos/browser/images/readme_banner.png"/>
10
- </a>
11
- </p>
12
- <br/>
13
7
 
14
8
  ## 🔌 Installation
15
9
 
@@ -19,8 +13,132 @@ Install [npm](https://www.npmjs.org/package/style-xlsx-m):
19
13
  npm install style-xlsx-m
20
14
  ```
21
15
 
16
+ Install [yarn](https://www.npmjs.org/package/style-xlsx-m):
17
+
18
+ ```sh
19
+ yarn add style-xlsx-m
20
+ ```
21
+
22
22
  Install browser:
23
23
 
24
24
  ```html
25
25
  <script src="dist/xlsx.js"></script>
26
- ```
26
+ ```
27
+
28
+ ## 🗒 Core API
29
+
30
+ - Refer to the [SheetJS](https://sheetjs.com/) documentation for core API reference
31
+ - Current version of sheetjs used: **0.18.5**
32
+ - Over time, will be added new and customized features.
33
+
34
+ ## 🗒 Style API
35
+ -- Method to export file in excel with style get from [xlsx-js-style](https://www.npmjs.com/package/xlsx-js-style) (only function writeFile)
36
+
37
+ ### Cell Style Example
38
+
39
+ ```js
40
+ // STEP 1: Create a new workbook
41
+ const wb = XLSX.utils.book_new();
42
+
43
+ // STEP 2: Create data rows and styles
44
+ let row = [
45
+ { v: "line\nbreak", t: "s", s: { alignment: { wrapText: true } } },
46
+ { v: "Courier: 24", t: "s", s: { font: { name: "Courier", sz: 24 } } },
47
+ { v: "fill: color", t: "s", s: { fill: { fgColor: { rgb: "E9E9E9" } } } },
48
+ { v: "bold & color", t: "s", s: { font: { bold: true, color: { rgb: "FF0000" } } } },
49
+ ];
50
+
51
+ // STEP 3: Create worksheet with rows; Add worksheet to workbook
52
+ const ws = XLSX.utils.aoa_to_sheet([row]);
53
+ XLSX.utils.book_append_sheet(wb, ws, "readme demo");
54
+
55
+ // STEP 4: Write Excel file to browser
56
+ XLSX.writeFile(wb, "xlsx-js-style-demo.xlsx");
57
+ ```
58
+
59
+ ### Cell Style Properties
60
+
61
+ - Cell styles are specified by a style object that roughly parallels the OpenXML structure.
62
+ - Style properties currently supported are: `alignment`, `border`, `fill`, `font`, `numFmt`.
63
+
64
+ | Style Prop | Sub Prop | Default | Description/Values |
65
+ | :---------- | :------------- | :---------- | ------------------------------------------------------------------------------------------------- |
66
+ | `alignment` | `vertical` | `bottom` | `"top"` or `"center"` or `"bottom"` |
67
+ | | `horizontal` | `left` | `"left"` or `"center"` or `"right"` |
68
+ | | `wrapText` | `false` | `true` or `false` |
69
+ | | `textRotation` | `0` | `0` to `180`, or `255` // `180` is rotated down 180 degrees, `255` is special, aligned vertically |
70
+ | `border` | `top` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
71
+ | | `bottom` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
72
+ | | `left` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
73
+ | | `right` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
74
+ | | `diagonal` | | `{ style: BORDER_STYLE, color: COLOR_STYLE, diagonalUp: true/false, diagonalDown: true/false }` |
75
+ | `fill` | `patternType` | `"none"` | `"solid"` or `"none"` |
76
+ | | `fgColor` | | foreground color: see `COLOR_STYLE` |
77
+ | | `bgColor` | | background color: see `COLOR_STYLE` |
78
+ | `font` | `bold` | `false` | font bold `true` or `false` |
79
+ | | `color` | | font color `COLOR_STYLE` |
80
+ | | `italic` | `false` | font italic `true` or `false` |
81
+ | | `name` | `"Calibri"` | font name |
82
+ | | `strike` | `false` | font strikethrough `true` or `false` |
83
+ | | `sz` | `"11"` | font size (points) |
84
+ | | `underline` | `false` | font underline `true` or `false` |
85
+ | | `vertAlign` | | `"superscript"` or `"subscript"` |
86
+ | `numFmt` | | `0` | Ex: `"0"` // integer index to built in formats, see StyleBuilder.SSF property |
87
+ | | | | Ex: `"0.00%"` // string matching a built-in format, see StyleBuilder.SSF |
88
+ | | | | Ex: `"0.0%"` // string specifying a custom format |
89
+ | | | | Ex: `"0.00%;\\(0.00%\\);\\-;@"` // string specifying a custom format, escaping special characters |
90
+ | | | | Ex: `"m/dd/yy"` // string a date format using Excel's format notation |
91
+
92
+ ### `COLOR_STYLE` {object} Properties
93
+
94
+ Colors for `border`, `fill`, `font` are specified as an name/value object - use one of the following:
95
+
96
+ | Color Prop | Description | Example |
97
+ | :--------- | ----------------- | --------------------------------------------------------------- |
98
+ | `rgb` | hex RGB value | `{rgb: "FFCC00"}` |
99
+ | `theme` | theme color index | `{theme: 4}` // (0-n) // Theme color index 4 ("Blue, Accent 1") |
100
+ | `tint` | tint by percent | `{theme: 1, tint: 0.4}` // ("Blue, Accent 1, Lighter 40%") |
101
+
102
+ ### `BORDER_STYLE` {string} Properties
103
+
104
+ Border style property is one of the following values:
105
+
106
+ - `dashDotDot`
107
+ - `dashDot`
108
+ - `dashed`
109
+ - `dotted`
110
+ - `hair`
111
+ - `mediumDashDotDot`
112
+ - `mediumDashDot`
113
+ - `mediumDashed`
114
+ - `medium`
115
+ - `slantDashDot`
116
+ - `thick`
117
+ - `thin`
118
+
119
+ **Border Notes**
120
+
121
+ Borders for merged areas are specified for each cell within the merged area. For example, to apply a box border to a merged area of 3x3 cells, border styles would need to be specified for eight different cells:
122
+
123
+ - left borders (for the three cells on the left)
124
+ - right borders (for the cells on the right)
125
+ - top borders (for the cells on the top)
126
+ - bottom borders (for the cells on the left)
127
+
128
+ ## 🙏 Thanks
129
+
130
+ This project is a fork of [SheetJS/sheetjs](https://github.com/sheetjs/sheetjs) combined with code and documentation from
131
+ [xlsx-js-style](https://www.npmjs.com/package/xlsx-js-style) (by [brentely](https://www.npmjs.com/~brentely)).
132
+
133
+ All projects are under the Apache 2.0 License
134
+
135
+ - [sheetjs](https://github.com/SheetJS/sheetjs)
136
+ - [js-xlsx](https://github.com/protobi/js-xlsx)
137
+ - [sheetjs-style](https://www.npmjs.com/package/sheetjs-style)
138
+ - [sheetjs-style-v2](https://www.npmjs.com/package/sheetjs-style-v2)
139
+ - [xlsx-js-style](https://www.npmjs.com/package/xlsx-js-style)
140
+
141
+ ## 🔖 License
142
+
143
+ Please consult the attached [LICENSE](https://github.com/MOR8T/STYLE-XSLX-M/main/LICENSE) file for details. All rights not explicitly
144
+ granted by the Apache 2.0 License are reserved by the Original Author.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "style-xlsx-m",
3
- "version": "0.1.7",
4
- "author": "mor8t",
5
- "description": "SheetJS and with Style! Get and Export Excel with basic styling options using JavaScript. But only get in xlsx and xlsm format.",
3
+ "version": "0.1.9",
4
+ "author": "mor8t (Shahrom)",
5
+ "description": "style-xlsx-m is a custom XLSX (SheetJs) library with styling (xlsx-js-style)",
6
6
  "keywords": [
7
7
  "excel",
8
8
  "xls",
@@ -15,7 +15,8 @@
15
15
  "dif",
16
16
  "sylk",
17
17
  "office",
18
- "spreadsheet"
18
+ "spreadsheet",
19
+ "style"
19
20
  ],
20
21
  "bin": {
21
22
  "xlsx": "./bin/xlsx.njs"