style-xlsx-m 0.1.6 → 0.1.8

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 CHANGED
@@ -2,11 +2,11 @@
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) library with styling from [xlsx-js-style](https://www.npmjs.com/package/xlsx-js-style)
6
6
 
7
7
  <p align="center">
8
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"/>
9
+ <img alt="style-xlsx-m 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
10
  </a>
11
11
  </p>
12
12
  <br/>
@@ -19,8 +19,129 @@ Install [npm](https://www.npmjs.org/package/style-xlsx-m):
19
19
  npm install style-xlsx-m
20
20
  ```
21
21
 
22
+ Install [yarn](https://www.npmjs.org/package/style-xlsx-m):
23
+
24
+ ```sh
25
+ yarn add style-xlsx-m
26
+ ```
27
+
22
28
  Install browser:
23
29
 
24
30
  ```html
25
31
  <script src="dist/xlsx.js"></script>
26
- ```
32
+ ```
33
+
34
+ ## 🗒 Core API
35
+
36
+ - Refer to the [SheetJS](https://sheetjs.com/) documentation for core API reference
37
+ - Current version of sheetjs used: **0.18.5**
38
+ - Over time, new or customized features will be added.
39
+
40
+ ## 🗒 Style API
41
+ -- Method to save styles in excel ( writeFile ) get from [xlsx-js-style](https://www.npmjs.com/package/xlsx-js-style)
42
+
43
+ ### Cell Style Example
44
+
45
+ ```js
46
+ // STEP 1: Create a new workbook
47
+ const wb = XLSX.utils.book_new();
48
+
49
+ // STEP 2: Create data rows and styles
50
+ let row = [
51
+ { v: "line\nbreak", t: "s", s: { alignment: { wrapText: true } } },
52
+ { v: "Courier: 24", t: "s", s: { font: { name: "Courier", sz: 24 } } },
53
+ { v: "fill: color", t: "s", s: { fill: { fgColor: { rgb: "E9E9E9" } } } },
54
+ { v: "bold & color", t: "s", s: { font: { bold: true, color: { rgb: "FF0000" } } } },
55
+ ];
56
+
57
+ // STEP 3: Create worksheet with rows; Add worksheet to workbook
58
+ const ws = XLSX.utils.aoa_to_sheet([row]);
59
+ XLSX.utils.book_append_sheet(wb, ws, "readme demo");
60
+
61
+ // STEP 4: Write Excel file to browser
62
+ XLSX.writeFile(wb, "xlsx-js-style-demo.xlsx");
63
+ ```
64
+
65
+ ### Cell Style Properties
66
+
67
+ - Cell styles are specified by a style object that roughly parallels the OpenXML structure.
68
+ - Style properties currently supported are: `alignment`, `border`, `fill`, `font`, `numFmt`.
69
+
70
+ | Style Prop | Sub Prop | Default | Description/Values |
71
+ | :---------- | :------------- | :---------- | ------------------------------------------------------------------------------------------------- |
72
+ | `alignment` | `vertical` | `bottom` | `"top"` or `"center"` or `"bottom"` |
73
+ | | `horizontal` | `left` | `"left"` or `"center"` or `"right"` |
74
+ | | `wrapText` | `false` | `true` or `false` |
75
+ | | `textRotation` | `0` | `0` to `180`, or `255` // `180` is rotated down 180 degrees, `255` is special, aligned vertically |
76
+ | `border` | `top` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
77
+ | | `bottom` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
78
+ | | `left` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
79
+ | | `right` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
80
+ | | `diagonal` | | `{ style: BORDER_STYLE, color: COLOR_STYLE, diagonalUp: true/false, diagonalDown: true/false }` |
81
+ | `fill` | `patternType` | `"none"` | `"solid"` or `"none"` |
82
+ | | `fgColor` | | foreground color: see `COLOR_STYLE` |
83
+ | | `bgColor` | | background color: see `COLOR_STYLE` |
84
+ | `font` | `bold` | `false` | font bold `true` or `false` |
85
+ | | `color` | | font color `COLOR_STYLE` |
86
+ | | `italic` | `false` | font italic `true` or `false` |
87
+ | | `name` | `"Calibri"` | font name |
88
+ | | `strike` | `false` | font strikethrough `true` or `false` |
89
+ | | `sz` | `"11"` | font size (points) |
90
+ | | `underline` | `false` | font underline `true` or `false` |
91
+ | | `vertAlign` | | `"superscript"` or `"subscript"` |
92
+ | `numFmt` | | `0` | Ex: `"0"` // integer index to built in formats, see StyleBuilder.SSF property |
93
+ | | | | Ex: `"0.00%"` // string matching a built-in format, see StyleBuilder.SSF |
94
+ | | | | Ex: `"0.0%"` // string specifying a custom format |
95
+ | | | | Ex: `"0.00%;\\(0.00%\\);\\-;@"` // string specifying a custom format, escaping special characters |
96
+ | | | | Ex: `"m/dd/yy"` // string a date format using Excel's format notation |
97
+
98
+ ### `COLOR_STYLE` {object} Properties
99
+
100
+ Colors for `border`, `fill`, `font` are specified as an name/value object - use one of the following:
101
+
102
+ | Color Prop | Description | Example |
103
+ | :--------- | ----------------- | --------------------------------------------------------------- |
104
+ | `rgb` | hex RGB value | `{rgb: "FFCC00"}` |
105
+ | `theme` | theme color index | `{theme: 4}` // (0-n) // Theme color index 4 ("Blue, Accent 1") |
106
+ | `tint` | tint by percent | `{theme: 1, tint: 0.4}` // ("Blue, Accent 1, Lighter 40%") |
107
+
108
+ ### `BORDER_STYLE` {string} Properties
109
+
110
+ Border style property is one of the following values:
111
+
112
+ - `dashDotDot`
113
+ - `dashDot`
114
+ - `dashed`
115
+ - `dotted`
116
+ - `hair`
117
+ - `mediumDashDotDot`
118
+ - `mediumDashDot`
119
+ - `mediumDashed`
120
+ - `medium`
121
+ - `slantDashDot`
122
+ - `thick`
123
+ - `thin`
124
+
125
+ **Border Notes**
126
+
127
+ 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:
128
+
129
+ - left borders (for the three cells on the left)
130
+ - right borders (for the cells on the right)
131
+ - top borders (for the cells on the top)
132
+ - bottom borders (for the cells on the left)
133
+
134
+ ## 🙏 Thanks
135
+
136
+ This project is a fork of [SheetJS/sheetjs](https://github.com/sheetjs/sheetjs) combined with code from
137
+ [xlsx-js-style](https://www.npmjs.com/package/xlsx-js-style) (by [brentely](https://www.npmjs.com/~brentely)).
138
+
139
+ All projects are under the Apache 2.0 License
140
+
141
+ - [sheetjs](https://github.com/SheetJS/sheetjs)
142
+ - [xlsx-js-style](https://www.npmjs.com/package/xlsx-js-style)
143
+
144
+ ## 🔖 License
145
+
146
+ Please consult the attached [LICENSE](https://github.com/MOR8T/STYLE-XSLX-M/main/LICENSE) file for details. All rights not explicitly
147
+ 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.6",
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.8",
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"
package/types/index.d.ts CHANGED
@@ -842,7 +842,7 @@ export interface XLSX$Utils {
842
842
  book_new(): WorkBook;
843
843
 
844
844
  /** Append a worksheet to a workbook */
845
- book_append_sheet(workbook: WorkBook, worksheet: WorkSheet, name?: string, roll?: boolean, sheetName?:string): void;
845
+ book_append_sheet(workbook: WorkBook, worksheet: WorkSheet, name?: any|string, roll?: boolean, sheetName?:string): void;
846
846
 
847
847
  /** Set sheet visibility (visible/hidden/very hidden) */
848
848
  book_set_sheet_visibility(workbook: WorkBook, sheet: number|string, visibility: number): void;