@corbe30/fortune-excel 1.0.3 → 1.0.4
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/.vscode/settings.json +3 -0
- package/README.md +24 -24
- package/dist/HandleZip.js +90 -34
- package/dist/ImportHelper.d.ts +2 -0
- package/dist/ImportHelper.js +51 -0
- package/dist/ToExcel/ExcelBorder.js +141 -141
- package/dist/ToExcel/ExcelConvert.js +19 -8
- package/dist/ToExcel/ExcelFile.js +66 -22
- package/dist/ToExcel/ExcelImage.js +27 -17
- package/dist/ToExcel/ExcelStyle.js +7 -7
- package/dist/ToFortuneSheet/FortuneBase.js +84 -28
- package/dist/ToFortuneSheet/FortuneCell.js +205 -185
- package/dist/ToFortuneSheet/FortuneFile.js +117 -111
- package/dist/ToFortuneSheet/FortuneImage.js +35 -15
- package/dist/ToFortuneSheet/FortuneSheet.js +217 -191
- package/dist/ToFortuneSheet/ReadXml.js +114 -87
- package/dist/ToolbarItem.d.ts +12 -0
- package/dist/ToolbarItem.js +67 -0
- package/dist/Transform.d.ts +2 -0
- package/dist/Transform.js +78 -0
- package/dist/common/constant.js +24 -24
- package/dist/common/emf.js +5 -5
- package/dist/common/method.js +169 -162
- package/dist/icons/ExportIcon.d.ts +3 -0
- package/dist/icons/ExportIcon.js +7 -0
- package/dist/icons/ImportIcon.d.ts +3 -0
- package/dist/icons/ImportIcon.js +7 -0
- package/dist/main.d.ts +2 -2
- package/dist/main.js +2 -24
- package/package.json +2 -2
- package/storybook-static/assets/Color-6VNJS4EI-0c01ecf9.js +1 -0
- package/storybook-static/assets/DocsRenderer-NNNQARDV-8c85b0e9.js +364 -0
- package/storybook-static/assets/Page.stories-2589ebf6.css +1 -0
- package/storybook-static/assets/Page.stories-a573643a.js +1948 -0
- package/storybook-static/assets/WithTooltip-V3YHNWJZ-a3f0d923.js +1 -0
- package/storybook-static/assets/_commonjs-dynamic-modules-302442b1.js +1 -0
- package/storybook-static/assets/_commonjsHelpers-de833af9.js +1 -0
- package/storybook-static/assets/_getPrototype-1e53b583.js +3 -0
- package/storybook-static/assets/entry-preview-b21759a2.js +1 -0
- package/storybook-static/assets/entry-preview-docs-d14f77b2.js +54 -0
- package/storybook-static/assets/formatter-SWP5E3XI-02b41ceb.js +156 -0
- package/storybook-static/assets/iframe-b3040d49.js +1 -0
- package/storybook-static/assets/index-1b441bc2.js +1 -0
- package/storybook-static/assets/index-356e4a49.js +6 -0
- package/storybook-static/assets/index-8b3efc3f.js +9 -0
- package/storybook-static/assets/index-9322cee5.js +1 -0
- package/storybook-static/assets/preview-0ef86afd.js +7 -0
- package/storybook-static/assets/preview-1970e752.js +1 -0
- package/storybook-static/assets/preview-2d30111f.js +27 -0
- package/storybook-static/assets/preview-2ff2accb.js +1 -0
- package/storybook-static/assets/preview-30b54f76.js +20 -0
- package/storybook-static/assets/preview-ba2273f4.js +1 -0
- package/storybook-static/assets/preview-c56bf6ac.js +1 -0
- package/storybook-static/assets/preview-d01b88e8.js +17 -0
- package/storybook-static/assets/preview-da31036b.js +396 -0
- package/storybook-static/assets/react-18-0a210e0b.js +24 -0
- package/storybook-static/assets/syntaxhighlighter-MJWPISIS-6799d638.js +1 -0
- package/storybook-static/favicon.svg +7 -0
- package/storybook-static/iframe.html +460 -0
- package/storybook-static/index.html +127 -0
- package/storybook-static/index.json +1 -0
- package/storybook-static/project.json +1 -0
- package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-backgrounds-3/manager-bundle.js +12 -0
- package/storybook-static/sb-addons/essentials-backgrounds-3/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js +63 -0
- package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js.LEGAL.txt +18 -0
- package/storybook-static/sb-addons/essentials-measure-6/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-measure-6/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-outline-7/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-outline-7/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-toolbars-5/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-toolbars-5/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-viewport-4/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-viewport-4/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/interactions-8/manager-bundle.js +12 -0
- package/storybook-static/sb-addons/interactions-8/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/links-0/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/links-0/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-common-assets/fonts.css +31 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/sb-manager/WithTooltip-V3YHNWJZ-MXTFSDU5.js +1 -0
- package/storybook-static/sb-manager/chunk-5QAFKPS7.js +7 -0
- package/storybook-static/sb-manager/chunk-7PRFHFSS.js +9 -0
- package/storybook-static/sb-manager/chunk-XE6LDGTE.js +406 -0
- package/storybook-static/sb-manager/chunk-YDUB7CS6.js +348 -0
- package/storybook-static/sb-manager/chunk-ZEU7PDD3.js +1 -0
- package/storybook-static/sb-manager/formatter-SWP5E3XI-7BGIK6BL.js +156 -0
- package/storybook-static/sb-manager/globals-module-info.js +1 -0
- package/storybook-static/sb-manager/globals.js +1 -0
- package/storybook-static/sb-manager/index.js +1 -0
- package/storybook-static/sb-manager/runtime.js +1 -0
- package/storybook-static/sb-manager/syntaxhighlighter-MJWPISIS-JOSCT6CQ.js +1 -0
- package/storybook-static/sb-preview/globals.js +1 -0
- package/storybook-static/sb-preview/runtime.js +112 -0
- package/storybook-static/stories.json +1 -0
- package/tsconfig.json +4 -3
- package/.github/workflows/main.yml +0 -30
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
FortuneExcel is an import/export library for [FortuneSheet](https://github.com/ruilisi/fortune-sheet/).
|
|
4
4
|
It only supports .xlsx format files (not .xls).
|
|
5
5
|
|
|
6
|
-
It is a fork of (now archived) FortuneSheetExcel.
|
|
6
|
+
It is a fork of (now archived) [FortuneSheetExcel](https://github.com/zenmrp/FortuneSheetExcel).
|
|
7
7
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
@@ -16,34 +16,34 @@ Supports the following spreadsheet features in import/export:
|
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
-
> NOTE: to be modified as a plugin for FortuneSheet
|
|
20
|
-
|
|
21
19
|
For best results, import and export a single sheet at a time. Although you can force FortuneExcel to handle multiple sheets, certain configurations may break.
|
|
22
20
|
|
|
21
|
+
### React frontend
|
|
22
|
+
`ImportHelper` is a hidden component and only required when using `importToolBarItem`.
|
|
23
23
|
```js
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
24
|
+
import { importToolBarItem, ImportHelper, exportToolBarItem } from "fortune-excel";
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
const workbookRef = useRef();
|
|
28
|
+
const [key, setKey] = useState(0);
|
|
29
|
+
const [sheets, setSheets] = useState(data);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<ImportHelper setKey={setKey} setSheets={setSheets} sheetRef={workbookRef1} />
|
|
34
|
+
<Workbook
|
|
35
|
+
key={key}
|
|
36
|
+
data={sheets}
|
|
37
|
+
ref={workbookRef}
|
|
38
|
+
customToolbarItems={[exportToolBarItem(workbookRef), importToolBarItem()]}
|
|
39
|
+
/>
|
|
40
|
+
</>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
30
43
|
```
|
|
31
44
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
f = await (
|
|
36
|
-
await import("node:fs/promises")
|
|
37
|
-
).readFile("/home/val/Downloads/Silkscreen.xlsx");
|
|
38
|
-
console.log(
|
|
39
|
-
(
|
|
40
|
-
await (
|
|
41
|
-
await import("FortuneSheetExcel")
|
|
42
|
-
).FortuneExcel.transformExcelToFortune(f)
|
|
43
|
-
).toJsonString()
|
|
44
|
-
);
|
|
45
|
-
// in dev: console.log((await (await import("./dist/main.js")).FortuneExcel.transformExcelToFortune(f)).toJsonString())
|
|
46
|
-
```
|
|
45
|
+
### Node backend
|
|
46
|
+
to be updated
|
|
47
47
|
|
|
48
48
|
## Authors and acknowledgment
|
|
49
49
|
|
package/dist/HandleZip.js
CHANGED
|
@@ -1,37 +1,93 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
1
37
|
import JSZip from "jszip";
|
|
2
|
-
|
|
3
|
-
|
|
38
|
+
var HandleZip = /** @class */ (function () {
|
|
39
|
+
function HandleZip(file) {
|
|
4
40
|
this.uploadFile = file;
|
|
5
41
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
HandleZip.prototype.unzipFile = function () {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var zip, fileList, _i, _a, _b, _path, zipEntry, fileName, fileNameArr, suffix, fileType, data;
|
|
45
|
+
return __generator(this, function (_c) {
|
|
46
|
+
switch (_c.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, JSZip.loadAsync(this.uploadFile)];
|
|
48
|
+
case 1:
|
|
49
|
+
zip = _c.sent();
|
|
50
|
+
fileList = {};
|
|
51
|
+
_i = 0, _a = Object.entries(zip.files);
|
|
52
|
+
_c.label = 2;
|
|
53
|
+
case 2:
|
|
54
|
+
if (!(_i < _a.length)) return [3 /*break*/, 5];
|
|
55
|
+
_b = _a[_i], _path = _b[0], zipEntry = _b[1];
|
|
56
|
+
fileName = zipEntry.name;
|
|
57
|
+
fileNameArr = fileName.split(".");
|
|
58
|
+
suffix = fileNameArr[fileNameArr.length - 1].toLowerCase();
|
|
59
|
+
fileType = "string";
|
|
60
|
+
if (suffix in
|
|
61
|
+
{
|
|
62
|
+
png: 1,
|
|
63
|
+
jpeg: 1,
|
|
64
|
+
jpg: 1,
|
|
65
|
+
gif: 1,
|
|
66
|
+
bmp: 1,
|
|
67
|
+
tif: 1,
|
|
68
|
+
webp: 1,
|
|
69
|
+
}) {
|
|
70
|
+
fileType = "base64";
|
|
71
|
+
}
|
|
72
|
+
else if (suffix == "emf") {
|
|
73
|
+
fileType = "arraybuffer";
|
|
74
|
+
}
|
|
75
|
+
return [4 /*yield*/, zipEntry.async(fileType)];
|
|
76
|
+
case 3:
|
|
77
|
+
data = _c.sent();
|
|
78
|
+
if (fileType == "base64") {
|
|
79
|
+
data = "data:image/" + suffix + ";base64," + data;
|
|
80
|
+
}
|
|
81
|
+
fileList[zipEntry.name] = data; // XXX: ignore EMF ArrayBuffer :/
|
|
82
|
+
_c.label = 4;
|
|
83
|
+
case 4:
|
|
84
|
+
_i++;
|
|
85
|
+
return [3 /*break*/, 2];
|
|
86
|
+
case 5: return [2 /*return*/, fileList];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
return HandleZip;
|
|
92
|
+
}());
|
|
93
|
+
export { HandleZip };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import React from "react";
|
|
38
|
+
import { transformExcelToFortune } from "./Transform.js";
|
|
39
|
+
export var ImportHelper = function (props) {
|
|
40
|
+
var setSheets = props.setSheets, setKey = props.setKey, sheetRef = props.sheetRef;
|
|
41
|
+
return (React.createElement("input", { type: "file", id: "ImportHelper", onChange: function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
switch (_a.label) {
|
|
44
|
+
case 0: return [4 /*yield*/, transformExcelToFortune(e, setSheets, setKey, sheetRef)];
|
|
45
|
+
case 1:
|
|
46
|
+
_a.sent();
|
|
47
|
+
return [2 /*return*/];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}); }, hidden: true }));
|
|
51
|
+
};
|