Skip to content

Commit 7664a04

Browse files
authored
Merge pull request #5 from gitbrent/sheetjs-update
Update to SheetJS version 0.18.5 and more
2 parents 088959a + 4bd807a commit 7664a04

File tree

268 files changed

+13083
-25855
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+13083
-25855
lines changed

README.md

Lines changed: 96 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,127 +2,144 @@
22

33
## ℹ️ About
44

5-
SheetJS with Style! Create Excel spreadsheets with basic styling options.
5+
SheetJS with Style! Create Excel spreadsheets with basic styling options using JavaScript.
66

7-
This project is a fork of [SheetJS/sheetjs](https://github.com/sheetjs/sheetjs) combined with code from
8-
[sheetjs-style](https://www.npmjs.com/package/sheetjs-style) (by [ShanaMaid](https://github.com/ShanaMaid/))
9-
and [sheetjs-style-v2](https://www.npmjs.com/package/sheetjs-style-v2) (by [Raul Gonzalez](https://www.npmjs.com/~armandourbina)).
7+
<p align="center">
8+
<a href="https://github.com/gitbrent/xlsx-js-style/">
9+
<img alt="xlsx-js-style sheetjs styles" title="xlsx-js-style sheetjs styles" src="https://raw.githubusercontent.com/gitbrent/xlsx-js-style/demos/browser/images/readme_banner.png"/>
10+
</a>
11+
</p>
12+
<br/>
1013

11-
All projects are under the Apache 2.0 License
14+
[![Known Vulnerabilities](https://snyk.io/test/npm/xlsx-js-style/badge.svg)](https://snyk.io/test/npm/xlsx-js-style) [![npm downloads](https://img.shields.io/npm/dm/xlsx-js-style.svg)](https://www.npmjs.com/package/xlsx-js-style)
15+
[![typescripts definitions](https://img.shields.io/npm/types/xlsx-js-style)](https://img.shields.io/npm/types/xlsx-js-style)
1216

1317
## 🔌 Installation
1418

1519
Install [npm](https://www.npmjs.org/package/xlsx-js-style):
1620

1721
```sh
18-
npm install xlsx-js-style --save
22+
npm install xlsx-js-style
1923
```
2024

2125
Install browser:
2226

2327
```html
24-
<script lang="javascript" src="dist/xlsx.bundle.js"></script>
28+
<script src="dist/xlsx.bundle.js"></script>
2529
```
2630

2731
## 🗒 Core API
2832

29-
Please refer to the [SheetJS](https://sheetjs.com/) documentation for core API reference.
33+
- Refer to the [SheetJS](https://sheetjs.com/) documentation for core API reference
34+
- Current version of sheetjs used: **0.18.5**
3035

3136
## 🗒 Style API
3237

3338
### Cell Style Example
3439

3540
```js
36-
ws["A1"].s = {
37-
font: {
38-
name: "Calibri",
39-
sz: 24,
40-
bold: true,
41-
color: { rgb: "FFFFAA00" },
42-
},
43-
};
41+
// STEP 1: Create a new workbook
42+
const wb = XLSX.utils.book_new();
43+
44+
// STEP 2: Create data rows and styles
45+
let row = [
46+
{ v: "Courier: 24", t: "s", s: { font: { name: "Courier", sz: 24 } } },
47+
{ v: "bold & color", t: "s", s: { font: { bold: true, color: { rgb: "FF0000" } } } },
48+
{ v: "fill: color", t: "s", s: { fill: { fgColor: { rgb: "E9E9E9" } } } },
49+
{ v: "line\nbreak", t: "s", s: { alignment: { wrapText: true } } },
50+
];
51+
52+
// STEP 3: Create worksheet with rows; Add worksheet to workbook
53+
const ws = XLSX.utils.aoa_to_sheet([row]);
54+
XLSX.utils.book_append_sheet(wb, ws, "readme demo");
55+
56+
// STEP 4: Write Excel file to browser
57+
XLSX.writeFile(wb, "xlsx-js-style-demo.xlsx");
4458
```
4559

4660
### Cell Style Properties
4761

48-
Cell styles are specified by a style object that roughly parallels the OpenXML structure. The style object has five
49-
top-level attributes: `fill`, `font`, `numFmt`, `alignment`, and `border`.
50-
51-
| Style Attribute | Sub Attributes | Values |
52-
| :-------------- | :------------- | :-------------------------------------------------------------------------------------------- |
53-
| fill | patternType | `"solid"` or `"none"` |
54-
| | fgColor | `COLOR_SPEC` |
55-
| | bgColor | `COLOR_SPEC` |
56-
| font | name | `"Calibri"` // default |
57-
| | sz | `"11"` // font size in points |
58-
| | color | `COLOR_SPEC` |
59-
| | bold | `true` or `false` |
60-
| | underline | `true` or `false` |
61-
| | italic | `true` or `false` |
62-
| | strike | `true` or `false` |
63-
| | outline | `true` or `false` |
64-
| | shadow | `true` or `false` |
65-
| | vertAlign | `true` or `false` |
66-
| numFmt | | `"0"` // integer index to built in formats, see StyleBuilder.SSF property |
67-
| | | `"0.00%"` // string matching a built-in format, see StyleBuilder.SSF |
68-
| | | `"0.0%"` // string specifying a custom format |
69-
| | | `"0.00%;\\(0.00%\\);\\-;@"` // string specifying a custom format, escaping special characters |
70-
| | | `"m/dd/yy"` // string a date format using Excel's format notation |
71-
| alignment | vertical | `"bottom"` or `"center"` or `"top"` |
72-
| | horizontal | `"left"` or `"center"` or `"right"` |
73-
| | wrapText | `true ` or ` false` |
74-
| | readingOrder | `2` // for right-to-left |
75-
| | textRotation | Number from `0` to `180` or `255` (default is `0`) |
76-
| | | `90` is rotated up 90 degrees |
77-
| | | `45` is rotated up 45 degrees |
78-
| | | `135` is rotated down 45 degrees |
79-
| | | `180` is rotated down 180 degrees |
80-
| | | `255` is special, aligned vertically |
81-
| border | top | `{ style: BORDER_STYLE, color: COLOR_SPEC }` |
82-
| | bottom | `{ style: BORDER_STYLE, color: COLOR_SPEC }` |
83-
| | left | `{ style: BORDER_STYLE, color: COLOR_SPEC }` |
84-
| | right | `{ style: BORDER_STYLE, color: COLOR_SPEC }` |
85-
| | diagonal | `{ style: BORDER_STYLE, color: COLOR_SPEC }` |
86-
| | diagonalUp | `true` or `false` |
87-
| | diagonalDown | `true` or `false` |
88-
89-
**COLOR_SPEC**: Colors for `fill`, `font`, and `border` are specified as objects, either:
90-
91-
- `{ auto: 1}` specifying automatic values
92-
- `{ rgb: "FFFFAA00" }` specifying a hex ARGB value
93-
- `{ theme: "1", tint: "-0.25"}` specifying an integer index to a theme color and a tint value (default 0)
94-
- `{ indexed: 64}` default value for `fill.bgColor`
95-
96-
**BORDER_STYLE**: Border style is a string value which may take on one of the following values:
62+
- Cell styles are specified by a style object that roughly parallels the OpenXML structure.
63+
- Style properties currently supported are: `alignment`, `border`, `fill`, `font`, `numFmt`.
64+
65+
| Style Prop | Sub Prop | Default | Description/Values |
66+
| :---------- | :------------- | :---------- | ------------------------------------------------------------------------------------------------- |
67+
| `alignment` | `vertical` | `bottom` | `"top"` or `"center"` or `"bottom"` |
68+
| | `horizontal` | `left` | `"left"` or `"center"` or `"right"` |
69+
| | `wrapText` | `false` | `true` or `false` |
70+
| | `textRotation` | `0` | `0` to `180`, or `255` // `180` is rotated down 180 degrees, `255` is special, aligned vertically |
71+
| `border` | `top` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
72+
| | `bottom` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
73+
| | `left` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
74+
| | `right` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
75+
| | `diagonal` | | `{ style: BORDER_STYLE, color: COLOR_STYLE, diagonalUp: true/false, diagonalDown: true/false }` |
76+
| `fill` | `patternType` | `"none"` | `"solid"` or `"none"` |
77+
| | `fgColor` | | foreground color: see `COLOR_STYLE` |
78+
| | `bgColor` | | background color: see `COLOR_STYLE` |
79+
| `font` | `bold` | `false` | font bold `true` or `false` |
80+
| | `color` | | font color `COLOR_STYLE` |
81+
| | `italic` | `false` | font italic `true` or `false` |
82+
| | `name` | `"Calibri"` | font name |
83+
| | `strike` | `false` | font strikethrough `true` or `false` |
84+
| | `sz` | `"11"` | font size (points) |
85+
| | `underline` | `false` | font underline `true` or `false` |
86+
| | `vertAlign` | | `"superscript"` or `"subscript"` |
87+
| `numFmt` | | `0` | Ex: `"0"` // integer index to built in formats, see StyleBuilder.SSF property |
88+
| | | | Ex: `"0.00%"` // string matching a built-in format, see StyleBuilder.SSF |
89+
| | | | Ex: `"0.0%"` // string specifying a custom format |
90+
| | | | Ex: `"0.00%;\\(0.00%\\);\\-;@"` // string specifying a custom format, escaping special characters |
91+
| | | | Ex: `"m/dd/yy"` // string a date format using Excel's format notation |
92+
93+
### `COLOR_STYLE` {object} Properties
94+
95+
Colors for `border`, `fill`, `font` are specified as an name/value object - use one of the following:
96+
97+
| Color Prop | Description | Example |
98+
| :--------- | ----------------- | --------------------------------------------------------------- |
99+
| `rgb` | hex RGB value | `{rgb: "FFCC00"}` |
100+
| `theme` | theme color index | `{theme: 4}` // (0-n) // Theme color index 4 ("Blue, Accent 1") |
101+
| `tint` | tint by percent | `{theme: 1, tint: 0.4}` // ("Blue, Accent 1, Lighter 40%") |
102+
103+
### `BORDER_STYLE` {string} Properties
104+
105+
Border style property is one of the following values:
97106

98-
- `thin`
99-
- `medium`
100-
- `thick`
107+
- `dashDotDot`
108+
- `dashDot`
109+
- `dashed`
101110
- `dotted`
102111
- `hair`
103-
- `dashed`
104-
- `mediumDashed`
105-
- `dashDot`
106-
- `mediumDashDot`
107-
- `dashDotDot`
108112
- `mediumDashDotDot`
113+
- `mediumDashDot`
114+
- `mediumDashed`
115+
- `medium`
109116
- `slantDashDot`
117+
- `thick`
118+
- `thin`
119+
120+
**Border Notes**
110121

111-
Borders for merged areas are specified for each cell within the merged area. So to apply a box border to a merged area of 3x3 cells, border styles would need to be specified for eight different cells:
122+
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:
112123

113-
- left borders for the three cells on the left,
114-
- right borders for the cells on the right
115-
- top borders for the cells on the top
116-
- bottom borders for the cells on the left
124+
- left borders (for the three cells on the left)
125+
- right borders (for the cells on the right)
126+
- top borders (for the cells on the top)
127+
- bottom borders (for the cells on the left)
117128

118129
## 🙏 Thanks
119130

131+
This project is a fork of [SheetJS/sheetjs](https://github.com/sheetjs/sheetjs) combined with code from
132+
[sheetjs-style](https://www.npmjs.com/package/sheetjs-style) (by [ShanaMaid](https://github.com/ShanaMaid/))
133+
and [sheetjs-style-v2](https://www.npmjs.com/package/sheetjs-style-v2) (by [Raul Gonzalez](https://www.npmjs.com/~armandourbina)).
134+
135+
All projects are under the Apache 2.0 License
136+
120137
- [sheetjs](https://github.com/SheetJS/sheetjs)
121138
- [js-xlsx](https://github.com/protobi/js-xlsx)
122139
- [sheetjs-style](https://www.npmjs.com/package/sheetjs-style)
123140
- [sheetjs-style-v2](https://www.npmjs.com/package/sheetjs-style-v2)
124141

125142
## 🔖 License
126143

127-
Please consult the attached LICENSE file for details. All rights not explicitly
144+
Please consult the attached [LICENSE](https://github.com/gitbrent/xlsx-js-style/blob/master/LICENSE) file for details. All rights not explicitly
128145
granted by the Apache 2.0 License are reserved by the Original Author.

demos-sheetjs/README.md

Lines changed: 0 additions & 57 deletions
This file was deleted.

demos-sheetjs/altjs/.gitignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

demos-sheetjs/altjs/.swiftlint.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

demos-sheetjs/altjs/Makefile

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)