@20baht/export 0.1.4 → 0.1.5
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/dist/sheet.d.ts +2 -0
- package/dist/xlsx.js +11 -4
- package/package.json +1 -1
package/dist/sheet.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export interface CellLook {
|
|
|
36
36
|
underline?: boolean;
|
|
37
37
|
/** The text's colour, `#rrggbb`. */
|
|
38
38
|
color?: string;
|
|
39
|
+
/** The text's size in points (6 to 72). Unset: 11. */
|
|
40
|
+
size?: number;
|
|
39
41
|
/** A light grey fill: a header, a band. */
|
|
40
42
|
shade?: boolean;
|
|
41
43
|
/** A fill of this colour, `#rrggbb`; it wins over `shade`. */
|
package/dist/xlsx.js
CHANGED
|
@@ -45,6 +45,10 @@ const VERTICAL = {
|
|
|
45
45
|
const sidesOf = (border) => border === true
|
|
46
46
|
? SIDES.join(',')
|
|
47
47
|
: SIDES.filter((side) => border !== undefined && border !== false && border.includes(side)).join(',');
|
|
48
|
+
const DEFAULT_SIZE = 11;
|
|
49
|
+
const sizeOf = (size) => size !== undefined && Number.isFinite(size)
|
|
50
|
+
? Math.min(72, Math.max(6, Math.round(size * 2) / 2))
|
|
51
|
+
: DEFAULT_SIZE;
|
|
48
52
|
class Styles {
|
|
49
53
|
#formats = new Map();
|
|
50
54
|
#looks = new Map();
|
|
@@ -68,8 +72,9 @@ class Styles {
|
|
|
68
72
|
look.align ?? '',
|
|
69
73
|
look.border === true ? '' : sidesOf(look.border),
|
|
70
74
|
look.valign ?? '',
|
|
75
|
+
look.size === undefined || look.size === DEFAULT_SIZE ? '' : String(look.size),
|
|
71
76
|
].join('|');
|
|
72
|
-
const key = flags + (more === '
|
|
77
|
+
const key = flags + (more === '|||||||' ? '' : `${more}|`) + (format ?? '');
|
|
73
78
|
if (key === '00000')
|
|
74
79
|
return 0;
|
|
75
80
|
if (key === '10000')
|
|
@@ -93,13 +98,15 @@ class Styles {
|
|
|
93
98
|
return 164 + at;
|
|
94
99
|
}
|
|
95
100
|
#font(look) {
|
|
101
|
+
const size = sizeOf(look.size);
|
|
96
102
|
const parts = (look.bold === true ? '<b/>' : '') +
|
|
97
103
|
(look.italic === true ? '<i/>' : '') +
|
|
98
104
|
(look.underline === true ? '<u/>' : '') +
|
|
105
|
+
`<sz val="${String(size)}"/>` +
|
|
99
106
|
(look.color === undefined ? '' : `<color rgb="FF${rgb(look.color)}"/>`);
|
|
100
|
-
if (parts ===
|
|
107
|
+
if (parts === `<sz val="${String(DEFAULT_SIZE)}"/>`)
|
|
101
108
|
return 0;
|
|
102
|
-
if (parts ===
|
|
109
|
+
if (parts === `<b/><sz val="${String(DEFAULT_SIZE)}"/>`)
|
|
103
110
|
return 1;
|
|
104
111
|
let at = this.#fonts.get(parts);
|
|
105
112
|
if (at === undefined) {
|
|
@@ -164,7 +171,7 @@ class Styles {
|
|
|
164
171
|
`<fonts count="${String(this.#fonts.size + 2)}"><font><sz val="11"/><name val="Calibri"/></font><font><b/><sz val="11"/><name val="Calibri"/></font>${[
|
|
165
172
|
...this.#fonts.keys(),
|
|
166
173
|
]
|
|
167
|
-
.map((parts) => `<font>${parts}<
|
|
174
|
+
.map((parts) => `<font>${parts}<name val="Calibri"/></font>`)
|
|
168
175
|
.join('')}</fonts>` +
|
|
169
176
|
`<fills count="${String(this.#fills.size + 2)}"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill>${[
|
|
170
177
|
...this.#fills.keys(),
|