abstract-sheet 0.0.3 → 0.0.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.
Files changed (47) hide show
  1. package/README.md +1 -1
  2. package/lib/abstract-sheet/abstract-sheet-xsd.d.ts +1 -1
  3. package/lib/abstract-sheet/abstract-sheet-xsd.d.ts.map +1 -1
  4. package/lib/abstract-sheet/abstract-sheet-xsd.js +41 -45
  5. package/lib/abstract-sheet/abstract-sheet-xsd.js.map +1 -1
  6. package/lib/abstract-sheet/abstract-sheet.d.ts +23 -9
  7. package/lib/abstract-sheet/abstract-sheet.d.ts.map +1 -1
  8. package/lib/abstract-sheet/abstract-sheet.js.map +1 -1
  9. package/lib/abstract-sheet-exporters/_style.d.ts +3 -0
  10. package/lib/abstract-sheet-exporters/_style.d.ts.map +1 -0
  11. package/lib/abstract-sheet-exporters/_style.js +113 -0
  12. package/lib/abstract-sheet-exporters/_style.js.map +1 -0
  13. package/lib/abstract-sheet-exporters/_xlsx-sheet.d.ts +2 -3
  14. package/lib/abstract-sheet-exporters/_xlsx-sheet.d.ts.map +1 -1
  15. package/lib/abstract-sheet-exporters/_xlsx-sheet.js +14 -116
  16. package/lib/abstract-sheet-exporters/_xlsx-sheet.js.map +1 -1
  17. package/lib/abstract-sheet-exporters/csv.d.ts +2 -2
  18. package/lib/abstract-sheet-exporters/csv.d.ts.map +1 -1
  19. package/lib/abstract-sheet-exporters/csv.js +19 -16
  20. package/lib/abstract-sheet-exporters/csv.js.map +1 -1
  21. package/lib/abstract-sheet-exporters/index.d.ts +1 -0
  22. package/lib/abstract-sheet-exporters/index.d.ts.map +1 -1
  23. package/lib/abstract-sheet-exporters/index.js +1 -0
  24. package/lib/abstract-sheet-exporters/index.js.map +1 -1
  25. package/lib/abstract-sheet-exporters/react.d.ts +5 -0
  26. package/lib/abstract-sheet-exporters/react.d.ts.map +1 -0
  27. package/lib/abstract-sheet-exporters/react.js +135 -0
  28. package/lib/abstract-sheet-exporters/react.js.map +1 -0
  29. package/lib/abstract-sheet-exporters/xlsx.d.ts +1 -1
  30. package/lib/abstract-sheet-exporters/xlsx.d.ts.map +1 -1
  31. package/lib/abstract-sheet-exporters/xlsx.js +8 -5
  32. package/lib/abstract-sheet-exporters/xlsx.js.map +1 -1
  33. package/lib/abstract-sheet-xml/abstract-sheet-xml.d.ts +3 -1
  34. package/lib/abstract-sheet-xml/abstract-sheet-xml.d.ts.map +1 -1
  35. package/lib/abstract-sheet-xml/abstract-sheet-xml.js +34 -23
  36. package/lib/abstract-sheet-xml/abstract-sheet-xml.js.map +1 -1
  37. package/package.json +6 -2
  38. package/src/abstract-sheet/abstract-sheet-xsd.ts +41 -45
  39. package/src/abstract-sheet/abstract-sheet-xsd.xml +41 -45
  40. package/src/abstract-sheet/abstract-sheet.ts +11 -12
  41. package/src/abstract-sheet-exporters/_style.ts +113 -0
  42. package/src/abstract-sheet-exporters/_xlsx-sheet.ts +19 -121
  43. package/src/abstract-sheet-exporters/csv.ts +23 -19
  44. package/src/abstract-sheet-exporters/index.ts +1 -0
  45. package/src/abstract-sheet-exporters/react.tsx +185 -0
  46. package/src/abstract-sheet-exporters/xlsx.ts +9 -6
  47. package/src/abstract-sheet-xml/abstract-sheet-xml.ts +36 -23
@@ -1,29 +1,30 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
1
+ <?xml version="1.1" encoding="UTF-8"?>
2
2
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3
3
 
4
4
  <xs:element name="AbstractSheet">
5
5
  <xs:complexType>
6
6
  <xs:sequence>
7
- <xs:element name="Styles" type="Styles" minOccurs="0" />
8
- <xs:element name="Sheets" type="Sheets" minOccurs="0" />
7
+ <xs:element name="Styles" type="Styles" minOccurs="0" maxOccurs="1" />
8
+ <xs:element name="Sheet" type="Sheet" />
9
9
  </xs:sequence>
10
10
  </xs:complexType>
11
11
  </xs:element>
12
12
 
13
-
14
- <xs:complexType name="Sheets">
15
- <xs:sequence>
16
- <xs:element name="Sheet" type="Sheet" minOccurs="0" />
17
- </xs:sequence>
18
- </xs:complexType>
19
-
20
13
  <xs:complexType name="Sheet">
21
14
  <xs:sequence>
22
- <xs:element name="Rows" type="Rows" minOccurs="0" maxOccurs="1" />
15
+ <xs:element name="Cells" type="Cells" />
23
16
  <xs:element name="RowInfos" type="RowInfos" minOccurs="0" maxOccurs="1" />
24
17
  <xs:element name="ColInfos" type="ColInfos" minOccurs="0" maxOccurs="1" />
25
18
  </xs:sequence>
26
19
  <xs:attribute name="name" type="xs:string" use="required" />
20
+ <xs:attribute name="direction">
21
+ <xs:simpleType>
22
+ <xs:restriction base="xs:string">
23
+ <xs:enumeration value="row" />
24
+ <xs:enumeration value="col" />
25
+ </xs:restriction>
26
+ </xs:simpleType>
27
+ </xs:attribute>
27
28
  </xs:complexType>
28
29
 
29
30
  <xs:complexType name="ColInfos">
@@ -48,43 +49,20 @@
48
49
  <xs:attribute name="heightPixels" type="xs:integer" />
49
50
  </xs:complexType>
50
51
 
51
-
52
- <xs:complexType name="Rows">
53
- <xs:sequence>
54
- <xs:element name="Row" type="Row" />
55
- </xs:sequence>
56
- </xs:complexType>
57
-
58
- <xs:complexType name="Row">
52
+ <xs:complexType name="Cells">
59
53
  <xs:sequence>
60
54
  <xs:element name="Cell" type="Cell" />
61
55
  </xs:sequence>
62
56
  </xs:complexType>
63
57
 
64
58
  <xs:complexType name="Cell">
65
- <xs:attribute name="value" type="NumberOrString" use="required" />
59
+ <xs:attribute name="number" type="xs:string" use="optional" />
60
+ <xs:attribute name="text" type="xs:string" use="optional" />
61
+ <xs:attribute name="bool" type="xs:string" use="optional" />
62
+ <xs:attribute name="date" type="xs:string" use="optional" />
66
63
  <xs:attribute name="styles" type="xs:string" />
67
- <xs:attribute name="type">
68
- <xs:simpleType>
69
- <xs:restriction base="xs:string">
70
- <xs:enumeration value="string" />
71
- <xs:enumeration value="number" />
72
- </xs:restriction>
73
- </xs:simpleType>
74
- </xs:attribute>
75
64
  </xs:complexType>
76
65
 
77
- <xs:simpleType name="NumberOrString">
78
- <xs:union>
79
- <xs:simpleType>
80
- <xs:restriction base="xs:double" />
81
- </xs:simpleType>
82
- <xs:simpleType>
83
- <xs:restriction base="xs:string" />
84
- </xs:simpleType>
85
- </xs:union>
86
- </xs:simpleType>
87
-
88
66
  <xs:complexType name="Styles">
89
67
  <xs:sequence>
90
68
  <xs:element name="Style" minOccurs="0" maxOccurs="unbounded" />
@@ -112,9 +90,9 @@
112
90
  </xs:simpleType>
113
91
  </xs:attribute>
114
92
  <xs:attribute name="wrapText" type="xs:boolean" />
115
- <xs:attribute name="textRotation" type="xs:boolean" />
116
- <xs:attribute name="borderStyle" type="xs:string" />
117
- <xs:attribute name="borderColor" type="xs:string" />
93
+ <xs:attribute name="textRotation" type="xs:double" />
94
+ <xs:attribute name="borderStyle" type="BorderStyle" />
95
+ <xs:attribute name="borderColor" type="BorderColor" />
118
96
  <xs:attribute name="fillType">
119
97
  <xs:simpleType>
120
98
  <xs:restriction base="xs:string">
@@ -123,10 +101,10 @@
123
101
  </xs:restriction>
124
102
  </xs:simpleType>
125
103
  </xs:attribute>
126
- <xs:attribute name="foreground" type="xs:string" />
127
- <xs:attribute name="background" type="xs:string" />
104
+ <xs:attribute name="foreground" type="HexColorWithOpacity" />
105
+ <xs:attribute name="background" type="HexColorWithOpacity" />
128
106
  <xs:attribute name="bold" type="xs:boolean" />
129
- <xs:attribute name="color" type="xs:string" />
107
+ <xs:attribute name="color" type="HexColorWithOpacity" />
130
108
  <xs:attribute name="italic" type="xs:boolean" />
131
109
  <xs:attribute name="font" type="xs:string" />
132
110
  <xs:attribute name="strike" type="xs:boolean" />
@@ -143,4 +121,22 @@
143
121
  <xs:attribute name="numberFormat" type="xs:string" />
144
122
  </xs:complexType>
145
123
 
124
+ <xs:simpleType name="HexColorWithOpacity">
125
+ <xs:restriction base="xs:string">
126
+ <xs:pattern value="#[0-9a-fA-F]{8}" />
127
+ </xs:restriction>
128
+ </xs:simpleType>
129
+
130
+ <xs:simpleType name="BorderColor">
131
+ <xs:restriction base="xs:string">
132
+ <xs:pattern value="^#([0-9a-fA-F]{6}|[0-9a-fA-F]{8})(\s#([0-9a-fA-F]{6}|[0-9a-fA-F]{8})){0,3}$" />
133
+ </xs:restriction>
134
+ </xs:simpleType>
135
+
136
+ <xs:simpleType name="BorderStyle">
137
+ <xs:restriction base="xs:string">
138
+ <xs:pattern value="^(dashDotDot|dashDot|dashed|dotted|hair|mediumDashDotDot|mediumDashDot|mediumDashed|medium|slantDashDot|thick|thin)(\s(dashDotDot|dashDot|dashed|dotted|hair|mediumDashDotDot|mediumDashDot|mediumDashed|medium|slantDashDot|thick|thin)){0,3}$" />
139
+ </xs:restriction>
140
+ </xs:simpleType>
141
+
146
142
  </xs:schema>
@@ -1,15 +1,15 @@
1
1
  export type AbstractSheet = {
2
- readonly sheets: Sheets;
2
+ readonly sheets: ReadonlyArray<Sheet>;
3
3
  readonly styles?: Styles;
4
+ readonly name?: string;
4
5
  };
5
6
 
6
- export type Sheets = ReadonlyArray<Sheet>;
7
-
8
7
  export type Sheet = {
9
8
  readonly name: string;
10
- readonly rows: Rows;
9
+ readonly cells: ReadonlyArray<Cells>;
11
10
  readonly colInfo?: ColInfos;
12
11
  readonly rowInfo?: RowInfos;
12
+ readonly direction?: "row" | "col";
13
13
  };
14
14
 
15
15
  export type ColInfos = ReadonlyArray<ColInfo>;
@@ -20,17 +20,16 @@ export type RowInfos = ReadonlyArray<RowInfo>;
20
20
 
21
21
  export type RowInfo = { readonly hidden?: boolean; readonly heightPixels?: number };
22
22
 
23
- export type Rows = ReadonlyArray<Row>;
23
+ export type Cells = ReadonlyArray<Cell>;
24
24
 
25
- export type Row = ReadonlyArray<Cell>;
25
+ export type Cell = (NumberCell | TextCell | BoolCell | DateCell) & { readonly styles?: ReadonlyArray<string> };
26
26
 
27
- export type Cell = {
28
- readonly value: string | number;
29
- readonly styles?: ReadonlyArray<string>;
30
- readonly type: CellType;
31
- };
27
+ export type NumberCell = { readonly type: "number"; readonly value: string | number | boolean | Date };
28
+ export type TextCell = { readonly type: "string"; readonly value: string | number | boolean | Date };
29
+ export type BoolCell = { readonly type: "boolean"; readonly value: string | number | boolean | Date };
30
+ export type DateCell = { readonly type: "date"; readonly value: string | number | boolean | Date };
32
31
 
33
- export type CellType = "string" | "number";
32
+ export type CellType = Cell["type"];
34
33
 
35
34
  export type Styles = ReadonlyArray<Style>;
36
35
 
@@ -0,0 +1,113 @@
1
+ import { Style } from "../abstract-sheet/abstract-sheet";
2
+
3
+ export function createStyle(style: Style): any {
4
+ let s: any = {};
5
+ if (style.vertical || style.horizontal || style.wrapText !== undefined || style.textRotation !== undefined) {
6
+ s.alignment = {};
7
+ if (style.vertical) {
8
+ s.alignment.vertical = style.vertical;
9
+ }
10
+ if (style.horizontal) {
11
+ s.alignment.horizontal = style.horizontal;
12
+ }
13
+ if (style.wrapText !== undefined) {
14
+ s.alignment.wrapText = style.wrapText;
15
+ }
16
+ if (style.textRotation !== undefined) {
17
+ s.alignment.textRotation = style.textRotation;
18
+ }
19
+ }
20
+ if (style.fillType || style.foreground || style.background) {
21
+ s.fill = {};
22
+ if (style.fillType) {
23
+ s.fill.patternType = style.fillType;
24
+ }
25
+ if (style.foreground) {
26
+ s.fill.fgColor = { rgb: style.foreground.slice(1) };
27
+ }
28
+ if (style.background) {
29
+ s.fill.bgColor = { rgb: style.background.slice(1) };
30
+ }
31
+ }
32
+
33
+ if (style.borderStyle || style.borderColor) {
34
+ s.border = {};
35
+ if (style.borderStyle?.top || style.borderColor?.top) {
36
+ s.border.top = {};
37
+ }
38
+ if (style.borderStyle?.top) {
39
+ s.border.top.style = style.borderStyle.top;
40
+ }
41
+ if (style.borderColor?.top) {
42
+ s.border.top.color = { rgb: style.borderColor.top.slice(1) };
43
+ }
44
+ if (style.borderStyle?.right || style.borderColor?.right) {
45
+ s.border.right = {};
46
+ }
47
+ if (style.borderStyle?.right) {
48
+ s.border.right.style = style.borderStyle.right;
49
+ }
50
+ if (style.borderColor?.right) {
51
+ s.border.right.color = { rgb: style.borderColor.right.slice(1) };
52
+ }
53
+ if (style.borderStyle?.bottom || style.borderColor?.bottom) {
54
+ s.border.bottom = {};
55
+ }
56
+ if (style.borderStyle?.bottom) {
57
+ s.border.bottom.style = style.borderStyle.bottom;
58
+ }
59
+ if (style.borderColor?.bottom) {
60
+ s.border.bottom.color = { rgb: style.borderColor.bottom.slice(1) };
61
+ }
62
+ if (style.borderStyle?.left || style.borderColor?.left) {
63
+ s.border.left = {};
64
+ }
65
+ if (style.borderStyle?.left) {
66
+ s.border.left.style = style.borderStyle.left;
67
+ }
68
+ if (style.borderColor?.left) {
69
+ s.border.left.color = { rgb: style.borderColor.left.slice(1) };
70
+ }
71
+ }
72
+
73
+ if (
74
+ style.bold !== undefined ||
75
+ style.color ||
76
+ style.italic !== undefined ||
77
+ style.font ||
78
+ style.strike !== undefined ||
79
+ style.size !== undefined ||
80
+ style.underline !== undefined ||
81
+ style.script
82
+ ) {
83
+ s.font = {};
84
+ if (style.bold !== undefined) {
85
+ s.font.bold = style.bold;
86
+ }
87
+ if (style.color) {
88
+ s.font.color = { rgb: style.color.slice(1) };
89
+ }
90
+ if (style.italic !== undefined) {
91
+ s.font.italic = style.italic;
92
+ }
93
+ if (style.font) {
94
+ s.font.name = style.font;
95
+ }
96
+ if (style.strike !== undefined) {
97
+ s.font.strike = style.strike;
98
+ }
99
+ if (style.size !== undefined) {
100
+ s.font.sz = style.size;
101
+ }
102
+ if (style.underline !== undefined) {
103
+ s.font.underline = style.underline;
104
+ }
105
+ if (style.script !== undefined) {
106
+ s.font.vertAlign = style.script;
107
+ }
108
+ }
109
+ if (style.numberFormat !== undefined) {
110
+ s.font.numFmt = style.numberFormat;
111
+ }
112
+ return s;
113
+ }
@@ -1,11 +1,11 @@
1
1
  import * as XLSX from "xlsx-js-style";
2
- import { Style, CellType, Sheet } from "../abstract-sheet/abstract-sheet";
2
+ import { CellType, Sheet } from "../abstract-sheet/abstract-sheet";
3
3
 
4
- export function xlsxWorkSheet(s: Sheet, styles: Record<string, any>): XLSX.WorkSheet {
4
+ export function xlsxWorkSheet(sheet: Sheet, styles: Record<string, any>): XLSX.WorkSheet {
5
5
  let colMax = -1;
6
6
  const cells: Record<string, XLSX.CellObject> = {};
7
- for (let ri = 0; ri < s.rows.length; ri++) {
8
- const r = s.rows[ri]!;
7
+ for (let ri = 0; ri < sheet.cells.length; ri++) {
8
+ const r = sheet.cells[ri]!;
9
9
  colMax = Math.max(r.length, colMax);
10
10
  for (let ci = 0; ci < r.length; ci++) {
11
11
  const c = r[ci]!;
@@ -15,23 +15,33 @@ export function xlsxWorkSheet(s: Sheet, styles: Record<string, any>): XLSX.WorkS
15
15
  s = { ...s!, ...styles[style] };
16
16
  }
17
17
  }
18
- cells[`${XLSX.utils.encode_col(ci)}${ri + 1}`] = { v: c.value, t: columnType(c.type), s };
18
+ const key =
19
+ sheet.direction === "col" ? `${XLSX.utils.encode_col(ri)}${ci + 1}` : `${XLSX.utils.encode_col(ci)}${ri + 1}`;
20
+ cells[key] = { v: c.value, t: cellObject(c.type), s };
19
21
  }
20
22
  }
21
23
 
22
24
  return {
23
25
  "!type": "sheet",
24
- "!ref": `A1:${XLSX.utils.encode_col(colMax)}${s.rows.length}`,
25
- "!cols": s.colInfo?.map((i): XLSX.ColInfo => ({ wpx: i.widthPixels, hidden: i.hidden })),
26
- "!rows": s.rowInfo?.map((i): XLSX.RowInfo => ({ hpx: i.heightPixels, hidden: i.hidden })),
26
+ "!ref": `A1:${
27
+ sheet.direction === "col"
28
+ ? `${XLSX.utils.encode_col(sheet.cells.length)}${colMax}`
29
+ : `${XLSX.utils.encode_col(colMax)}${sheet.cells.length}`
30
+ }`,
31
+ "!cols": sheet.colInfo?.map((i): XLSX.ColInfo => ({ wpx: i.widthPixels ?? 64, hidden: i.hidden })),
32
+ "!rows": sheet.rowInfo?.map((i): XLSX.RowInfo => ({ hpx: i.heightPixels ?? 15, hidden: i.hidden })),
27
33
  ...cells,
28
34
  };
29
35
  }
30
36
 
31
- const columnType = (colType: CellType | undefined): XLSX.CellObject["t"] => {
37
+ const cellObject = (colType: CellType | undefined): XLSX.CellObject["t"] => {
32
38
  switch (colType) {
33
39
  case "number":
34
40
  return "n";
41
+ case "boolean":
42
+ return "b";
43
+ case "date":
44
+ return "d";
35
45
  case undefined:
36
46
  case "string":
37
47
  return "s";
@@ -42,115 +52,3 @@ const columnType = (colType: CellType | undefined): XLSX.CellObject["t"] => {
42
52
  };
43
53
 
44
54
  const exhaustiveCheck = (check: never): never => check;
45
-
46
- export function createStyle(style: Style): any {
47
- let s: any = {};
48
- if (style.vertical || style.horizontal || style.wrapText !== undefined || style.textRotation !== undefined) {
49
- s.alignment = {};
50
- if (style.vertical) {
51
- s.alignment.vertical = style.vertical;
52
- }
53
- if (style.horizontal) {
54
- s.alignment.horizontal = style.horizontal;
55
- }
56
- if (style.wrapText !== undefined) {
57
- s.alignment.wrapText = style.wrapText;
58
- }
59
- if (style.textRotation !== undefined) {
60
- s.alignment.textRotation = style.textRotation;
61
- }
62
- }
63
- if (style.fillType || style.foreground || style.background) {
64
- s.fill = {};
65
- if (style.fillType) {
66
- s.fill.patternType = style.fillType;
67
- }
68
- if (style.foreground) {
69
- s.fill.fgColor = { rgb: style.foreground };
70
- }
71
- if (style.background) {
72
- s.fill.bgColor = { rgb: style.background };
73
- }
74
- }
75
-
76
- if (style.borderStyle || style.borderColor) {
77
- s.border = {};
78
- if (style.borderStyle?.top || style.borderColor?.top) {
79
- s.border.top = {};
80
- }
81
- if (style.borderStyle?.top) {
82
- s.border.top.style = style.borderStyle.top;
83
- }
84
- if (style.borderColor?.top) {
85
- s.border.top.color = { rgb: style.borderColor.top };
86
- }
87
- if (style.borderStyle?.right || style.borderColor?.right) {
88
- s.border.right = {};
89
- }
90
- if (style.borderStyle?.right) {
91
- s.border.right.style = style.borderStyle.right;
92
- }
93
- if (style.borderColor?.right) {
94
- s.border.right.color = { rgb: style.borderColor.right };
95
- }
96
- if (style.borderStyle?.bottom || style.borderColor?.bottom) {
97
- s.border.bottom = {};
98
- }
99
- if (style.borderStyle?.bottom) {
100
- s.border.bottom.style = style.borderStyle.bottom;
101
- }
102
- if (style.borderColor?.bottom) {
103
- s.border.bottom.color = { rgb: style.borderColor.bottom };
104
- }
105
- if (style.borderStyle?.left || style.borderColor?.left) {
106
- s.border.left = {};
107
- }
108
- if (style.borderStyle?.left) {
109
- s.border.left.style = style.borderStyle.left;
110
- }
111
- if (style.borderColor?.left) {
112
- s.border.left.color = { rgb: style.borderColor.left };
113
- }
114
- }
115
-
116
- if (
117
- style.bold !== undefined ||
118
- style.color ||
119
- style.italic !== undefined ||
120
- style.font ||
121
- style.strike !== undefined ||
122
- style.size !== undefined ||
123
- style.underline !== undefined ||
124
- style.script
125
- ) {
126
- s.font = {};
127
- if (style.bold !== undefined) {
128
- s.font.bold = style.bold;
129
- }
130
- if (style.color) {
131
- s.font.color = { rgb: style.color };
132
- }
133
- if (style.italic !== undefined) {
134
- s.font.italic = style.italic;
135
- }
136
- if (style.font) {
137
- s.font.name = style.font;
138
- }
139
- if (style.strike !== undefined) {
140
- s.font.strike = style.strike;
141
- }
142
- if (style.size !== undefined) {
143
- s.font.sz = style.size;
144
- }
145
- if (style.underline !== undefined) {
146
- s.font.underline = style.underline;
147
- }
148
- if (style.script !== undefined) {
149
- s.font.vertAlign = style.script;
150
- }
151
- }
152
- if (style.numberFormat !== undefined) {
153
- s.font.numFmt = style.numberFormat;
154
- }
155
- return s;
156
- }
@@ -1,11 +1,12 @@
1
1
  import * as XLSX from "xlsx-js-style";
2
2
  import { AbstractSheet } from "../abstract-sheet/abstract-sheet";
3
- import { createStyle, xlsxWorkSheet } from "./_xlsx-sheet";
3
+ import { xlsxWorkSheet } from "./_xlsx-sheet";
4
+ import { createStyle } from "./_style";
4
5
 
5
6
  export type CsvFile = { readonly name: string; readonly csv: string };
6
7
 
7
8
  export function toCsv(
8
- as: AbstractSheet,
9
+ abstractSheets: ReadonlyArray<AbstractSheet>,
9
10
  options?: {
10
11
  readonly separator?: string;
11
12
  readonly rowSeparator?: string;
@@ -16,21 +17,24 @@ export function toCsv(
16
17
  readonly rawNumber?: boolean;
17
18
  readonly dateFormat?: string;
18
19
  }
19
- ): ReadonlyArray<CsvFile> {
20
- const styles = Object.fromEntries(as.styles?.map((s) => [s.name, createStyle(s)]) ?? []);
21
- const mappedOptions: XLSX.Sheet2CSVOpts | undefined = options
22
- ? {
23
- FS: options.separator,
24
- RS: options.rowSeparator,
25
- strip: options.noTrailingSeparator,
26
- blankrows: options.blankRows,
27
- skipHidden: options.skipHidden,
28
- forceQuotes: options.forceQuotes,
29
- rawNumbers: options.rawNumber,
30
- dateNF: options.dateFormat,
31
- }
32
- : undefined;
33
- return as.sheets.map(
34
- (s): CsvFile => ({ name: s.name, csv: XLSX.utils.sheet_to_csv(xlsxWorkSheet(s, styles), mappedOptions) })
35
- );
20
+ ): ReadonlyArray<ReadonlyArray<CsvFile>> {
21
+ return (abstractSheets as Array<AbstractSheet>).map((as) => {
22
+ const styles = Object.fromEntries(as.styles?.map((s) => [s.name, createStyle(s)]) ?? []);
23
+ const mappedOptions: XLSX.Sheet2CSVOpts | undefined = options
24
+ ? {
25
+ FS: options.separator,
26
+ RS: options.rowSeparator,
27
+ strip: options.noTrailingSeparator,
28
+ blankrows: options.blankRows,
29
+ skipHidden: options.skipHidden,
30
+ forceQuotes: options.forceQuotes,
31
+ rawNumbers: options.rawNumber,
32
+ dateNF: options.dateFormat,
33
+ }
34
+ : undefined;
35
+
36
+ return as.sheets.map(
37
+ (s): CsvFile => ({ name: s.name, csv: XLSX.utils.sheet_to_csv(xlsxWorkSheet(s, styles), mappedOptions) })
38
+ );
39
+ }) as unknown as ReadonlyArray<ReadonlyArray<CsvFile>>;
36
40
  }
@@ -1,2 +1,3 @@
1
1
  export * from "./csv";
2
2
  export * from "./xlsx";
3
+ export * from "./react";