@corbe30/fortune-excel 2.1.2 → 2.2.2
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/README.md +16 -0
- package/dist/ToExcel/ExcelFile.d.ts +1 -1
- package/dist/ToExcel/ExcelFile.js +5 -3
- package/dist/ToExcel/ExportHelper.js +1 -1
- package/dist/common/Transform.d.ts +1 -1
- package/dist/common/Transform.js +15 -9
- package/dist/main.d.ts +1 -0
- package/dist/main.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,6 +53,22 @@ You can check the example in [Storybook](https://github.com/Corbe30/FortuneExcel
|
|
|
53
53
|
}
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
3. You can programmatically import/export as well:
|
|
57
|
+
```js
|
|
58
|
+
import { transformFortuneToExcel } from "@corbe30/fortune-excel";
|
|
59
|
+
|
|
60
|
+
const manualExport = async () => {
|
|
61
|
+
const exportedFile = await transformFortuneToExcel(
|
|
62
|
+
sheetRef.current,
|
|
63
|
+
"xlsx", // or "csv"; default = "xlsx"
|
|
64
|
+
true // if you want to start automatic download; default = true
|
|
65
|
+
);
|
|
66
|
+
console.log("Exported file data:", exportedFile);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
<button onClick={manualExport}>Try Manual Export!</button>
|
|
70
|
+
```
|
|
71
|
+
|
|
56
72
|
## Authors and acknowledgment
|
|
57
73
|
|
|
58
74
|
- [@Corbe30](https://github.com/Corbe30)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IFileType } from "../common/ICommon";
|
|
2
|
-
export declare function exportSheetExcel(luckysheetRef: any, fileType: IFileType): Promise<
|
|
2
|
+
export declare function exportSheetExcel(luckysheetRef: any, fileType: IFileType, download?: boolean): Promise<Blob>;
|
|
@@ -72,7 +72,8 @@ var ExcelBorder_1 = require("./ExcelBorder");
|
|
|
72
72
|
var ExcelValidation_1 = require("./ExcelValidation");
|
|
73
73
|
var ExcelConfig_1 = require("./ExcelConfig");
|
|
74
74
|
var ICommon_1 = require("../common/ICommon");
|
|
75
|
-
function exportSheetExcel(luckysheetRef, fileType) {
|
|
75
|
+
function exportSheetExcel(luckysheetRef, fileType, download) {
|
|
76
|
+
if (download === void 0) { download = true; }
|
|
76
77
|
return __awaiter(this, void 0, void 0, function () {
|
|
77
78
|
var luckysheet, workbook, fileData, buffer, buffer;
|
|
78
79
|
return __generator(this, function (_a) {
|
|
@@ -105,8 +106,9 @@ function exportSheetExcel(luckysheetRef, fileType) {
|
|
|
105
106
|
fileData = new Blob([buffer]);
|
|
106
107
|
_a.label = 4;
|
|
107
108
|
case 4:
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
if (download)
|
|
110
|
+
fileSaver.saveAs(fileData, "".concat(luckysheetRef.getSheet().name, ".").concat(fileType));
|
|
111
|
+
return [2 /*return*/, fileData];
|
|
110
112
|
}
|
|
111
113
|
});
|
|
112
114
|
});
|
|
@@ -49,7 +49,7 @@ var ExportHelper = function (props) {
|
|
|
49
49
|
exportHelper.style.visibility = "hidden";
|
|
50
50
|
};
|
|
51
51
|
var onClick = function (fileType) {
|
|
52
|
-
(0, Transform_1.transformFortuneToExcel)(sheetRef.current, fileType);
|
|
52
|
+
(0, Transform_1.transformFortuneToExcel)(sheetRef.current, fileType, true);
|
|
53
53
|
onMouseLeave();
|
|
54
54
|
};
|
|
55
55
|
return (react_1.default.createElement("div", { className: "export-helper", style: exportHelperStyle, onMouseLeave: onMouseLeave },
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IFileType } from "./ICommon";
|
|
2
2
|
export declare const transformExcelToFortune: (e: any, setSheets: any, setKey: any, sheetRef: any) => Promise<void>;
|
|
3
|
-
export declare const transformFortuneToExcel: (luckysheetRef: any, fileType
|
|
3
|
+
export declare const transformFortuneToExcel: (luckysheetRef: any, fileType?: IFileType, download?: boolean) => Promise<Blob>;
|
package/dist/common/Transform.js
CHANGED
|
@@ -63,6 +63,7 @@ exports.transformFortuneToExcel = exports.transformExcelToFortune = void 0;
|
|
|
63
63
|
var FortuneFile_1 = require("../ToFortuneSheet/FortuneFile");
|
|
64
64
|
var HandleZip_1 = require("../ToFortuneSheet/HandleZip");
|
|
65
65
|
var ExcelFile_1 = require("../ToExcel/ExcelFile");
|
|
66
|
+
var ICommon_1 = require("./ICommon");
|
|
66
67
|
var ExcelJS = __importStar(require("exceljs"));
|
|
67
68
|
var convertCsvToExcel = function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
69
|
var csvText, rows, workbook, worksheet, buffer;
|
|
@@ -125,14 +126,19 @@ var transformExcelToFortune = function (e, setSheets, setKey, sheetRef) { return
|
|
|
125
126
|
});
|
|
126
127
|
}); };
|
|
127
128
|
exports.transformExcelToFortune = transformExcelToFortune;
|
|
128
|
-
var transformFortuneToExcel = function (luckysheetRef, fileType
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
var transformFortuneToExcel = function (luckysheetRef, fileType, download) {
|
|
130
|
+
if (fileType === void 0) { fileType = ICommon_1.IFileType.XLSX; }
|
|
131
|
+
if (download === void 0) { download = true; }
|
|
132
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
133
|
+
var result;
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
switch (_a.label) {
|
|
136
|
+
case 0: return [4 /*yield*/, (0, ExcelFile_1.exportSheetExcel)(luckysheetRef, fileType, download)];
|
|
137
|
+
case 1:
|
|
138
|
+
result = _a.sent();
|
|
139
|
+
return [2 /*return*/, result];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
136
142
|
});
|
|
137
|
-
}
|
|
143
|
+
};
|
|
138
144
|
exports.transformFortuneToExcel = transformFortuneToExcel;
|
package/dist/main.d.ts
CHANGED
package/dist/main.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./common/ToolbarItem"), exports);
|
|
18
18
|
__exportStar(require("./common/FortuneExcelHelper"), exports);
|
|
19
|
+
__exportStar(require("./common/Transform"), exports);
|