@corbe30/fortune-excel 1.0.3

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 (44) hide show
  1. package/.github/workflows/main.yml +30 -0
  2. package/.github/workflows/publish.yml +30 -0
  3. package/.storybook/main.ts +18 -0
  4. package/.storybook/preview.ts +15 -0
  5. package/LICENSE +21 -0
  6. package/README.md +59 -0
  7. package/dist/HandleZip.d.ts +8 -0
  8. package/dist/HandleZip.js +37 -0
  9. package/dist/ICommon.d.ts +34 -0
  10. package/dist/ICommon.js +1 -0
  11. package/dist/ToExcel/ExcelBorder.d.ts +3 -0
  12. package/dist/ToExcel/ExcelBorder.js +1412 -0
  13. package/dist/ToExcel/ExcelConvert.d.ts +16 -0
  14. package/dist/ToExcel/ExcelConvert.js +92 -0
  15. package/dist/ToExcel/ExcelFile.d.ts +1 -0
  16. package/dist/ToExcel/ExcelFile.js +30 -0
  17. package/dist/ToExcel/ExcelImage.d.ts +2 -0
  18. package/dist/ToExcel/ExcelImage.js +64 -0
  19. package/dist/ToExcel/ExcelStyle.d.ts +3 -0
  20. package/dist/ToExcel/ExcelStyle.js +53 -0
  21. package/dist/ToFortuneSheet/FortuneBase.d.ts +133 -0
  22. package/dist/ToFortuneSheet/FortuneBase.js +28 -0
  23. package/dist/ToFortuneSheet/FortuneCell.d.ts +25 -0
  24. package/dist/ToFortuneSheet/FortuneCell.js +782 -0
  25. package/dist/ToFortuneSheet/FortuneFile.d.ts +50 -0
  26. package/dist/ToFortuneSheet/FortuneFile.js +432 -0
  27. package/dist/ToFortuneSheet/FortuneImage.d.ts +20 -0
  28. package/dist/ToFortuneSheet/FortuneImage.js +51 -0
  29. package/dist/ToFortuneSheet/FortuneSheet.d.ts +36 -0
  30. package/dist/ToFortuneSheet/FortuneSheet.js +581 -0
  31. package/dist/ToFortuneSheet/IFortune.d.ts +301 -0
  32. package/dist/ToFortuneSheet/IFortune.js +1 -0
  33. package/dist/ToFortuneSheet/ReadXml.d.ts +61 -0
  34. package/dist/ToFortuneSheet/ReadXml.js +337 -0
  35. package/dist/common/constant.d.ts +25 -0
  36. package/dist/common/constant.js +277 -0
  37. package/dist/common/emf.d.ts +3 -0
  38. package/dist/common/emf.js +1294 -0
  39. package/dist/common/method.d.ts +132 -0
  40. package/dist/common/method.js +1075 -0
  41. package/dist/main.d.ts +2 -0
  42. package/dist/main.js +24 -0
  43. package/package.json +47 -0
  44. package/tsconfig.json +13 -0
@@ -0,0 +1,30 @@
1
+ name: npm
2
+ on:
3
+ release:
4
+ types: [published]
5
+ workflow_dispatch:
6
+ permissions:
7
+ contents: read
8
+ pages: write
9
+ id-token: write
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: "20.x"
18
+ registry-url: "https://registry.npmjs.org"
19
+ - run: npm ci
20
+ - run: npm publish --tag latest --provenance --access public
21
+ env:
22
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
23
+ - run: npm run build-storybook
24
+ - uses: actions/upload-pages-artifact@v2
25
+ with:
26
+ path: storybook-static
27
+ - id: deploy
28
+ uses: actions/deploy-pages@v3
29
+ with:
30
+ token: ${{ github.token }}
@@ -0,0 +1,30 @@
1
+ name: npm
2
+ on:
3
+ release:
4
+ types: [published]
5
+ workflow_dispatch:
6
+ permissions:
7
+ contents: read
8
+ pages: write
9
+ id-token: write
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: "20.x"
18
+ registry-url: "https://registry.npmjs.org"
19
+ - run: npm ci
20
+ - run: npm publish --tag latest --provenance --access public
21
+ env:
22
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
23
+ - run: npm run build-storybook
24
+ - uses: actions/upload-pages-artifact@v2
25
+ with:
26
+ path: storybook-static
27
+ - id: deploy
28
+ uses: actions/deploy-pages@v3
29
+ with:
30
+ token: ${{ github.token }}
@@ -0,0 +1,18 @@
1
+ import type { StorybookConfig } from "@storybook/react-vite";
2
+
3
+ const config: StorybookConfig = {
4
+ stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
5
+ addons: [
6
+ "@storybook/addon-links",
7
+ "@storybook/addon-essentials",
8
+ "@storybook/addon-interactions",
9
+ ],
10
+ framework: {
11
+ name: "@storybook/react-vite",
12
+ options: {},
13
+ },
14
+ docs: {
15
+ autodocs: "tag",
16
+ },
17
+ };
18
+ export default config;
@@ -0,0 +1,15 @@
1
+ import type { Preview } from "@storybook/react";
2
+
3
+ const preview: Preview = {
4
+ parameters: {
5
+ actions: { argTypesRegex: "^on[A-Z].*" },
6
+ controls: {
7
+ matchers: {
8
+ color: /(background|color)$/i,
9
+ date: /Date$/i,
10
+ },
11
+ },
12
+ },
13
+ };
14
+
15
+ export default preview;
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020-present, Mengshukeji
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # FortuneExcel
2
+
3
+ FortuneExcel is an import/export library for [FortuneSheet](https://github.com/ruilisi/fortune-sheet/).
4
+ It only supports .xlsx format files (not .xls).
5
+
6
+ It is a fork of (now archived) FortuneSheetExcel.
7
+
8
+ ## Features
9
+
10
+ Supports the following spreadsheet features in import/export:
11
+
12
+ - Cell style
13
+ - Cell border
14
+ - Cell format, such as number format, date, percentage, etc.
15
+ - Formula
16
+
17
+ ## Usage
18
+
19
+ > NOTE: to be modified as a plugin for FortuneSheet
20
+
21
+ 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
+
23
+ ```js
24
+ import { transformExcelToFortune } from "FortuneSheetExcel";
25
+
26
+ // e.g. got a file input change event
27
+ const xls = await e.target.files[0].arrayBuffer();
28
+ const fsh = await transformExcelToFortune(xls);
29
+ setData(fsh.sheets); // use this as the Workbook data
30
+ ```
31
+
32
+ Interactively in a node repl:
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
+ ```
47
+
48
+ ## Authors and acknowledgment
49
+
50
+ - [@Corbe30](https://github.com/Corbe30)
51
+ - [@wbfsa](https://github.com/wbfsa)
52
+ - [@wpxp123456](https://github.com/wpxp123456)
53
+ - [@Dushusir](https://github.com/Dushusir)
54
+ - [@xxxDeveloper](https://github.com/xxxDeveloper)
55
+ - [@mengshukeji](https://github.com/mengshukeji)
56
+
57
+ ## License
58
+
59
+ [MIT](http://opensource.org/licenses/MIT)
@@ -0,0 +1,8 @@
1
+ import JSZip from "jszip";
2
+ import { IuploadfileList } from "./ICommon.js";
3
+ export declare class HandleZip {
4
+ uploadFile: File;
5
+ workBook: JSZip;
6
+ constructor(file: File);
7
+ unzipFile(): Promise<IuploadfileList>;
8
+ }
@@ -0,0 +1,37 @@
1
+ import JSZip from "jszip";
2
+ export class HandleZip {
3
+ constructor(file) {
4
+ this.uploadFile = file;
5
+ }
6
+ async unzipFile() {
7
+ const zip = await JSZip.loadAsync(this.uploadFile);
8
+ const fileList = {};
9
+ for (const [_path, zipEntry] of Object.entries(zip.files)) {
10
+ const fileName = zipEntry.name;
11
+ const fileNameArr = fileName.split(".");
12
+ const suffix = fileNameArr[fileNameArr.length - 1].toLowerCase();
13
+ let fileType = "string";
14
+ if (suffix in
15
+ {
16
+ png: 1,
17
+ jpeg: 1,
18
+ jpg: 1,
19
+ gif: 1,
20
+ bmp: 1,
21
+ tif: 1,
22
+ webp: 1,
23
+ }) {
24
+ fileType = "base64";
25
+ }
26
+ else if (suffix == "emf") {
27
+ fileType = "arraybuffer";
28
+ }
29
+ let data = await zipEntry.async(fileType);
30
+ if (fileType == "base64") {
31
+ data = "data:image/" + suffix + ";base64," + data;
32
+ }
33
+ fileList[zipEntry.name] = data; // XXX: ignore EMF ArrayBuffer :/
34
+ }
35
+ return fileList;
36
+ }
37
+ }
@@ -0,0 +1,34 @@
1
+ import { IfortunesheetDataVerificationType } from "./ToFortuneSheet/IFortune.js";
2
+ export interface IuploadfileList {
3
+ [index: string]: string;
4
+ }
5
+ export interface stringToNum {
6
+ [index: string]: number;
7
+ }
8
+ export interface numTostring {
9
+ [index: number]: string;
10
+ }
11
+ export interface IattributeList {
12
+ [index: string]: string;
13
+ }
14
+ export interface IDataVerificationMap {
15
+ [key: string]: IfortunesheetDataVerificationType;
16
+ }
17
+ export interface IDataVerificationType2Map {
18
+ [key: string]: {
19
+ [key: string]: string;
20
+ };
21
+ }
22
+ export interface IBorderSide {
23
+ color: string;
24
+ style: number;
25
+ }
26
+ export interface IBorderInfo {
27
+ b: IBorderSide;
28
+ l: IBorderSide;
29
+ r: IBorderSide;
30
+ t: IBorderSide;
31
+ }
32
+ export interface IBorderInfoCompute {
33
+ [key: string]: IBorderInfo;
34
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import ExcelJS from "exceljs";
2
+ declare var setBorder: (lucksheetfile: any, worksheet: ExcelJS.Worksheet) => void;
3
+ export { setBorder };