to-spreadsheet 0.0.2 → 0.1.0

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.
@@ -0,0 +1,2 @@
1
+ declare const generateRels: () => string;
2
+ export { generateRels };
@@ -1,10 +1,11 @@
1
- const generateRels = () =>
2
- `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateRels = void 0;
4
+ const generateRels = () => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3
5
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
4
6
  <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" />
5
7
  <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" />
6
8
  <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml" />
7
9
  </Relationships>
8
10
  `;
9
-
10
- export { generateRels };
11
+ exports.generateRels = generateRels;
@@ -0,0 +1,2 @@
1
+ declare const generateContentTypesXml: () => string;
2
+ export { generateContentTypesXml };
@@ -1,5 +1,7 @@
1
- const generateContentTypesXml = () =>
2
- `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateContentTypesXml = void 0;
4
+ const generateContentTypesXml = () => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3
5
  <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
4
6
  <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
5
7
  <Default Extension="xml" ContentType="application/xml" />
@@ -11,5 +13,4 @@ const generateContentTypesXml = () =>
11
13
  <Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" />
12
14
  </Types>
13
15
  `;
14
-
15
- export {generateContentTypesXml}
16
+ exports.generateContentTypesXml = generateContentTypesXml;
@@ -0,0 +1,2 @@
1
+ declare const generateAppXml: () => string;
2
+ export { generateAppXml };
@@ -1,5 +1,7 @@
1
- const generateAppXml = () =>
2
- `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateAppXml = void 0;
4
+ const generateAppXml = () => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3
5
  <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
4
6
  <Application>
5
7
  Microsoft Excel
@@ -47,5 +49,4 @@ const generateAppXml = () =>
47
49
  </AppVersion>
48
50
  </Properties>
49
51
  `;
50
-
51
- export {generateAppXml}
52
+ exports.generateAppXml = generateAppXml;
@@ -0,0 +1,2 @@
1
+ declare const generateCoreXml: (username?: string) => string;
2
+ export { generateCoreXml };
@@ -1,8 +1,13 @@
1
- import { format } from 'date-fns'
2
-
3
- const generateCoreXml = (username: string = "to-spreadsheet") => {
4
- const date = format(Date.now(), 'yyyy-MM-dd') + 'T' + format(Date.now(), 'HH:mm:ss') + 'Z'
5
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateCoreXml = void 0;
4
+ const date_fns_1 = require("date-fns");
5
+ const generateCoreXml = (username = "to-spreadsheet") => {
6
+ const date = (0, date_fns_1.format)(Date.now(), "yyyy-MM-dd") +
7
+ "T" +
8
+ (0, date_fns_1.format)(Date.now(), "HH:mm:ss") +
9
+ "Z";
10
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
6
11
  <coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
7
12
  <creator>
8
13
  ${username}
@@ -18,7 +23,5 @@ const generateCoreXml = (username: string = "to-spreadsheet") => {
18
23
  </modified>
19
24
  </coreProperties>
20
25
  `;
21
- }
22
-
23
-
24
- export {generateCoreXml}
26
+ };
27
+ exports.generateCoreXml = generateCoreXml;
@@ -0,0 +1,3 @@
1
+ import { ICellEntry } from "./xl/worksheets/sheet1.xml";
2
+ declare const generateExcel: (data: ICellEntry[][]) => void;
3
+ export { generateExcel };
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateExcel = void 0;
4
+ const _rels_1 = require("./_rels/.rels");
5
+ const app_xml_1 = require("./docProps/app.xml");
6
+ const core_xml_1 = require("./docProps/core.xml");
7
+ const content_types_xml_1 = require("./content-types.xml");
8
+ const workbook_xml_rels_1 = require("./xl/_rels/workbook.xml.rels");
9
+ const theme1_xml_1 = require("./xl/theme/theme1.xml");
10
+ const sheet1_xml_1 = require("./xl/worksheets/sheet1.xml");
11
+ const styles_xml_1 = require("./xl/styles.xml");
12
+ const workbook_xml_1 = require("./xl/workbook.xml");
13
+ const fs = require("fs");
14
+ const archiver = require("archiver");
15
+ const generateTree = (data) => {
16
+ return {
17
+ "[Content_Types].xml": (0, content_types_xml_1.generateContentTypesXml)(),
18
+ "_rels/.rels": (0, _rels_1.generateRels)(),
19
+ "docProps/app.xml": (0, app_xml_1.generateAppXml)(),
20
+ "docProps/core.xml": (0, core_xml_1.generateCoreXml)(),
21
+ "xl/_rels/workbook.xml.rels": (0, workbook_xml_rels_1.generateWorkBookXmlRels)(),
22
+ "xl/theme/theme1.xml": (0, theme1_xml_1.generateTheme1)(),
23
+ "xl/worksheets/sheet1.xml": (0, sheet1_xml_1.generateSheet1Xml)(data),
24
+ "xl/styles.xml": (0, styles_xml_1.generateStyleXml)(),
25
+ "xl/workbook.xml": (0, workbook_xml_1.generateWorkBookXml)(),
26
+ };
27
+ };
28
+ const generateExcel = (data) => {
29
+ const output = fs.createWriteStream(__dirname + "/example.xlsx");
30
+ const archive = archiver("zip", {
31
+ zlib: { level: 9 },
32
+ });
33
+ output.on("close", function () {
34
+ console.debug(archive.pointer() + " total bytes");
35
+ console.debug("archiver has been finalized and the output file descriptor has closed.");
36
+ });
37
+ output.on("end", function () {
38
+ console.debug("Data has been drained");
39
+ });
40
+ archive.on("warning", function (err) {
41
+ if (err.code === "ENOENT") {
42
+ }
43
+ else {
44
+ throw err;
45
+ }
46
+ });
47
+ archive.on("error", function (err) {
48
+ throw err;
49
+ });
50
+ archive.pipe(output);
51
+ Object.entries(generateTree(data)).map(([filename, fileContent]) => {
52
+ archive.append(fileContent, { name: filename });
53
+ });
54
+ archive.finalize();
55
+ };
56
+ exports.generateExcel = generateExcel;
package/lib/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { generateExcel } from "./generate-excel";
2
+ declare let sampleData: ({
3
+ readOnly: boolean;
4
+ value: string;
5
+ }[] | ({
6
+ readOnly: boolean;
7
+ value: number;
8
+ } | {
9
+ value: number;
10
+ readOnly?: undefined;
11
+ })[])[];
12
+ export { generateExcel, sampleData };
package/lib/index.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sampleData = exports.generateExcel = void 0;
4
+ const generate_excel_1 = require("./generate-excel");
5
+ Object.defineProperty(exports, "generateExcel", { enumerable: true, get: function () { return generate_excel_1.generateExcel; } });
6
+ let sampleData = [
7
+ [
8
+ { readOnly: true, value: "" },
9
+ { value: "A", readOnly: true },
10
+ { value: "B", readOnly: true },
11
+ { value: "C", readOnly: true },
12
+ { value: "D", readOnly: true },
13
+ { value: "D", readOnly: true },
14
+ ],
15
+ [
16
+ { readOnly: true, value: 1 },
17
+ { value: 1 },
18
+ { value: 3 },
19
+ { value: 3 },
20
+ { value: 3 },
21
+ ],
22
+ [
23
+ { readOnly: true, value: 2 },
24
+ { value: 2 },
25
+ { value: 4 },
26
+ { value: 4 },
27
+ { value: 4 },
28
+ ],
29
+ [
30
+ { readOnly: true, value: 3 },
31
+ { value: 1 },
32
+ { value: 3 },
33
+ { value: 3 },
34
+ { value: 3 },
35
+ ],
36
+ [
37
+ { readOnly: true, value: 4 },
38
+ { value: 2 },
39
+ { value: 4 },
40
+ { value: 4 },
41
+ { value: 4 },
42
+ ],
43
+ ];
44
+ exports.sampleData = sampleData;
@@ -0,0 +1,2 @@
1
+ declare const generateWorkBookXmlRels: () => string;
2
+ export { generateWorkBookXmlRels };
@@ -1,10 +1,11 @@
1
- const generateWorkBookXmlRels = () =>
2
- `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateWorkBookXmlRels = void 0;
4
+ const generateWorkBookXmlRels = () => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3
5
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
4
6
  <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml" />
5
7
  <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml" />
6
8
  <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml" />
7
9
  </Relationships>
8
10
  `;
9
-
10
- export {generateWorkBookXmlRels}
11
+ exports.generateWorkBookXmlRels = generateWorkBookXmlRels;
@@ -0,0 +1,2 @@
1
+ declare const generateStyleXml: () => string;
2
+ export { generateStyleXml };
@@ -1,5 +1,7 @@
1
- const generateStyleXml = () =>
2
- `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateStyleXml = void 0;
4
+ const generateStyleXml = () => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3
5
  <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac x16r2 xr" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:x16r2="http://schemas.microsoft.com/office/spreadsheetml/2015/02/main" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision">
4
6
  <fonts count="1" x14ac:knownFonts="1">
5
7
  <font>
@@ -48,5 +50,4 @@ const generateStyleXml = () =>
48
50
  </extLst>
49
51
  </styleSheet>
50
52
  `;
51
-
52
- export {generateStyleXml}
53
+ exports.generateStyleXml = generateStyleXml;
@@ -0,0 +1,2 @@
1
+ declare const generateTheme1: () => string;
2
+ export { generateTheme1 };
@@ -1,5 +1,7 @@
1
- const generateTheme1 = () =>
2
- `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateTheme1 = void 0;
4
+ const generateTheme1 = () => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3
5
  <theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme">
4
6
  <themeElements>
5
7
  <clrScheme name="Office">
@@ -293,5 +295,4 @@ const generateTheme1 = () =>
293
295
  </extLst>
294
296
  </theme>
295
297
  `;
296
-
297
- export {generateTheme1}
298
+ exports.generateTheme1 = generateTheme1;
@@ -0,0 +1,2 @@
1
+ declare const generateWorkBookXml: () => string;
2
+ export { generateWorkBookXml };
@@ -1,5 +1,7 @@
1
- const generateWorkBookXml = () =>
2
- `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateWorkBookXml = void 0;
4
+ const generateWorkBookXml = () => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3
5
  <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x15 xr xr6 xr10 xr2" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr6="http://schemas.microsoft.com/office/spreadsheetml/2016/revision6" xmlns:xr10="http://schemas.microsoft.com/office/spreadsheetml/2016/revision10" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2">
4
6
  <fileVersion appName="xl" lastEdited="7" lowestEdited="7" rupBuild="25427" />
5
7
  <workbookPr defaultThemeVersion="166925" />
@@ -30,6 +32,5 @@ const generateWorkBookXml = () =>
30
32
  </ext>
31
33
  </extLst>
32
34
  </workbook>
33
- `
34
-
35
- export {generateWorkBookXml}
35
+ `;
36
+ exports.generateWorkBookXml = generateWorkBookXml;
@@ -0,0 +1,6 @@
1
+ interface ICellEntry {
2
+ readonly?: boolean;
3
+ value: number | string;
4
+ }
5
+ declare const generateSheet1Xml: (grid: ICellEntry[][]) => string;
6
+ export { ICellEntry, generateSheet1Xml };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateSheet1Xml = void 0;
4
+ const index = (value) => {
5
+ const base = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
6
+ value++;
7
+ let result = "";
8
+ do {
9
+ const remainder = value % 26;
10
+ result = base[(remainder || 26) - 1] + result;
11
+ value = Math.floor(value / 26);
12
+ } while (value > 0);
13
+ return result;
14
+ };
15
+ const row = (row, cellValues) => `<row r="${row}" spans="1:${cellValues.length}">${cellValues
16
+ .map((item, i) => cell(index(i) + row, item))
17
+ .join("")}</row>\n`;
18
+ const cell = (row, value) => ` <c r="${row}">${cellValue(value)}</c>\n`;
19
+ const cellValue = (value) => `<v>${value.value}</v>`;
20
+ const generateSheetData = (grid) => `<sheetData>${grid
21
+ .map((ro, index) => row(index, ro))
22
+ .join("")}</sheetData>`;
23
+ const generateSheet1Xml = (grid) => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
24
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac xr xr2 xr3" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" xr:uid="{6A0CD924-A203-41BB-8331-42E46B7D5F20}">
25
+ <dimension ref="B3:I7" />
26
+ <sheetViews>
27
+ <sheetView tabSelected="1" workbookViewId="0">
28
+ <selection activeCell="B3" sqref="B3:D4" />
29
+ </sheetView>
30
+ </sheetViews>
31
+ <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25" />
32
+ ${generateSheetData(grid)}
33
+ <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3" />
34
+ </worksheet>
35
+ `;
36
+ exports.generateSheet1Xml = generateSheet1Xml;
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "to-spreadsheet",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "description": "npm to package to create spreadsheet in node environment",
5
+ "main": "src/index.ts",
5
6
  "scripts": {
6
- "build": "npx tsc",
7
+ "prepare": "npm run build",
8
+ "build": "tsc",
7
9
  "test:compile": "npx ts-node src/index.ts"
8
10
  },
9
11
  "repository": {
@@ -20,6 +22,7 @@
20
22
  "archiver": "^5.3.1",
21
23
  "date-fns": "^2.29.3"
22
24
  },
25
+ "files": ["lib"],
23
26
  "devDependencies": {
24
27
  "@types/node": "^17.0.35",
25
28
  "ts-node": "^10.8.0",
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- import {generateExcel} from "./generate-excel";
1
+ import { generateExcel } from "./generate-excel";
2
2
 
3
- let data = [
3
+ let sampleData = [
4
4
  [
5
5
  { readOnly: true, value: "" },
6
6
  { value: "A", readOnly: true },
@@ -39,4 +39,6 @@ let data = [
39
39
  ],
40
40
  ];
41
41
 
42
- generateExcel(data);
42
+ // generateExcel(sampleData);
43
+
44
+ export { generateExcel, sampleData };
@@ -1,29 +0,0 @@
1
- name: Publish to NPM
2
-
3
- on:
4
- release:
5
- types: [published]
6
-
7
- jobs:
8
- build:
9
- runs-on: ubuntu-latest
10
-
11
- strategy:
12
- matrix:
13
- node-version: [16.x]
14
- registry-url: ['https://registry.npmjs.org']
15
-
16
- steps:
17
- - uses: actions/checkout@v2
18
- - uses: actions/setup-node@v2
19
- with:
20
- node-version: ${{ matrix.node-version }}
21
- registry-url: ${{ matrix.registry-url }}
22
- - name: 'Installing deps'
23
- run: npm i
24
- - name: 'Build'
25
- run: npm run build
26
- - name: 'Publish'
27
- run: npm publish
28
- env:
29
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,66 +0,0 @@
1
- import {generateRels} from "./_rels/.rels";
2
- import {generateAppXml} from "./docProps/app.xml";
3
- import { generateCoreXml} from "./docProps/core.xml";
4
- import {generateContentTypesXml} from "./content-types.xml";
5
- import {generateWorkBookXmlRels} from "./xl/_rels/workbook.xml.rels";
6
- import {generateTheme1} from "./xl/theme/theme1.xml";
7
- import {generateSheet1Xml, ICellEntry} from "./xl/worksheets/sheet1.xml";
8
- import {generateStyleXml} from "./xl/styles.xml";
9
- import {generateWorkBookXml} from "./xl/workbook.xml";
10
-
11
- const fs = require('fs');
12
- const archiver = require('archiver');
13
-
14
- const generateTree = (data:ICellEntry[][]) => { return{
15
- "[Content_Types].xml": generateContentTypesXml(),
16
- "_rels/.rels" : generateRels(),
17
- "docProps/app.xml": generateAppXml() ,
18
- "docProps/core.xml": generateCoreXml() ,
19
- "xl/_rels/workbook.xml.rels": generateWorkBookXmlRels(),
20
- "xl/theme/theme1.xml": generateTheme1() ,
21
- "xl/worksheets/sheet1.xml": generateSheet1Xml(data) ,
22
- "xl/styles.xml": generateStyleXml(),
23
- "xl/workbook.xml": generateWorkBookXml(),
24
- }
25
- }
26
-
27
-
28
- const generateExcel = (data:ICellEntry[][]) => {
29
- const output = fs.createWriteStream(__dirname + '/example.xlsx');
30
- const archive = archiver('zip', {
31
- zlib: { level: 9 }
32
- });
33
-
34
- output.on('close', function() {
35
- console.debug(archive.pointer() + ' total bytes');
36
- console.debug('archiver has been finalized and the output file descriptor has closed.');
37
- });
38
-
39
- output.on('end', function() {
40
- console.debug('Data has been drained');
41
- });
42
-
43
- archive.on('warning', function(err:any) {
44
- if (err.code === 'ENOENT') {
45
- // log warning
46
- } else {
47
- // throw error
48
- throw err;
49
- }
50
- });
51
-
52
- archive.on('error', function(err:any) {
53
- throw err;
54
- });
55
-
56
- archive.pipe(output);
57
-
58
-
59
- Object.entries(generateTree(data)).map((value)=>{
60
- archive.append(value[1], { name: value[0] });
61
- })
62
-
63
- archive.finalize();
64
- }
65
-
66
- export {generateExcel}
@@ -1,54 +0,0 @@
1
- interface ICellEntry {
2
- readonly?: boolean;
3
- value: number | string;
4
- }
5
-
6
- // 1->a, 2->b, 26->z, 27->aa
7
- const index = (value: number) => {
8
- const base = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
9
- value++;
10
- let result = "";
11
- do {
12
- const remainder = value % 26;
13
- result = base[(remainder || 26) - 1] + result;
14
- value = Math.floor(value / 26);
15
- } while (value > 0);
16
- return result;
17
- };
18
-
19
- const row = (row: number, cellValues: ICellEntry[]) =>
20
- `<row r="${row}" spans="1:${cellValues.length}">${cellValues
21
- .map((item: ICellEntry, i: number) => cell(index(i) + row, item))
22
- .join("")}</row>\n`;
23
-
24
- const cell = (row: string, value: ICellEntry) =>
25
- ` <c r="${row}">${cellValue(value)}</c>\n`;
26
-
27
- const cellValue = (value: ICellEntry) => `<v>${value.value}</v>`;
28
-
29
- const generateSheetData = (grid: ICellEntry[][]) =>
30
- `<sheetData>${grid
31
- .map((ro: ICellEntry[], index: number) => row(index, ro))
32
- .join("")}</sheetData>`;
33
-
34
-
35
-
36
-
37
- const generateSheet1Xml = (
38
- grid: ICellEntry[][]
39
- ) => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
40
- <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac xr xr2 xr3" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" xr:uid="{6A0CD924-A203-41BB-8331-42E46B7D5F20}">
41
- <dimension ref="B3:I7" />
42
- <sheetViews>
43
- <sheetView tabSelected="1" workbookViewId="0">
44
- <selection activeCell="B3" sqref="B3:D4" />
45
- </sheetView>
46
- </sheetViews>
47
- <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25" />
48
- ${generateSheetData(grid)}
49
- <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3" />
50
- </worksheet>
51
- `;
52
-
53
-
54
- export { ICellEntry, generateSheet1Xml };
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "@tsconfig/node16/tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "dist"
5
- },
6
- "include": ["src"],
7
- "exclude": ["node_modules"]
8
- }