gemcap-be-common 1.4.62 → 1.4.63
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/helpers/excel.helper.d.ts +21 -0
- package/helpers/excel.helper.js +25 -1
- package/helpers/excel.helper.ts +30 -2
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -29,6 +29,21 @@ export interface IExcelJsCell {
|
|
|
29
29
|
border?: Partial<ExcelJS.Borders>;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
export declare const cellStyles: {
|
|
33
|
+
title: {
|
|
34
|
+
font: {
|
|
35
|
+
bold: boolean;
|
|
36
|
+
};
|
|
37
|
+
border: {
|
|
38
|
+
bottom: {
|
|
39
|
+
style: ExcelJS.BorderStyle;
|
|
40
|
+
color: {
|
|
41
|
+
argb: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
32
47
|
export declare const convertDataToFile: (dataToConvert: {
|
|
33
48
|
[sheetName: string]: any[];
|
|
34
49
|
}[]) => Promise<any>;
|
|
@@ -63,3 +78,9 @@ export declare const convertDataToFileWithStyle: (dataToConvert: {
|
|
|
63
78
|
export declare const addHeaderToData: (header: {
|
|
64
79
|
[key: string]: string;
|
|
65
80
|
}, data: object[]) => {}[];
|
|
81
|
+
export declare const getColumnsWidths: (sheetNames: string[], columnWidth: {
|
|
82
|
+
[columnLetter: string]: number;
|
|
83
|
+
}) => {};
|
|
84
|
+
export declare const getSheetsOptions: (sheetNames: string[], options: {
|
|
85
|
+
showGridLines: boolean;
|
|
86
|
+
}) => {};
|
package/helpers/excel.helper.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.addHeaderToData = exports.convertDataToFileWithStyle = exports.convertDataToFileWithStyleOld = exports.convertDataToFile = exports.NUMBER_FORMATS = void 0;
|
|
29
|
+
exports.getSheetsOptions = exports.getColumnsWidths = exports.addHeaderToData = exports.convertDataToFileWithStyle = exports.convertDataToFileWithStyleOld = exports.convertDataToFile = exports.cellStyles = exports.NUMBER_FORMATS = void 0;
|
|
30
30
|
const XLSX = __importStar(require("xlsx"));
|
|
31
31
|
const XLSXStyle = __importStar(require("xlsx-js-style"));
|
|
32
32
|
const exceljs_1 = __importDefault(require("exceljs"));
|
|
@@ -42,6 +42,14 @@ exports.NUMBER_FORMATS = {
|
|
|
42
42
|
currencyFull$: '$#,##0.00',
|
|
43
43
|
currencyShort$: '$#,##0',
|
|
44
44
|
};
|
|
45
|
+
exports.cellStyles = {
|
|
46
|
+
title: {
|
|
47
|
+
font: { bold: true },
|
|
48
|
+
border: {
|
|
49
|
+
bottom: { style: 'medium', color: { argb: 'FF000000' } },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
45
53
|
const defaultColumnWidth = 20;
|
|
46
54
|
const convertDataToFile = async (dataToConvert) => {
|
|
47
55
|
const wb = XLSX.utils.book_new();
|
|
@@ -229,3 +237,19 @@ const addHeaderToData = (header, data) => {
|
|
|
229
237
|
return [header, ...processedItems];
|
|
230
238
|
};
|
|
231
239
|
exports.addHeaderToData = addHeaderToData;
|
|
240
|
+
const getColumnsWidths = (sheetNames, columnWidth) => {
|
|
241
|
+
return sheetNames.reduce((acc, sheetName) => {
|
|
242
|
+
return {
|
|
243
|
+
...acc,
|
|
244
|
+
[sheetName]: columnWidth,
|
|
245
|
+
};
|
|
246
|
+
}, {});
|
|
247
|
+
};
|
|
248
|
+
exports.getColumnsWidths = getColumnsWidths;
|
|
249
|
+
const getSheetsOptions = (sheetNames, options) => {
|
|
250
|
+
return sheetNames.reduce((acc, sheetName) => ({
|
|
251
|
+
...acc,
|
|
252
|
+
[sheetName]: options,
|
|
253
|
+
}), {});
|
|
254
|
+
};
|
|
255
|
+
exports.getSheetsOptions = getSheetsOptions;
|
package/helpers/excel.helper.ts
CHANGED
|
@@ -34,6 +34,15 @@ export interface IExcelJsCell {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
export const cellStyles = {
|
|
38
|
+
title: {
|
|
39
|
+
font: { bold: true },
|
|
40
|
+
border: {
|
|
41
|
+
bottom: { style: 'medium' as ExcelJS.BorderStyle, color: { argb: 'FF000000' } },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
37
46
|
const defaultColumnWidth = 20;
|
|
38
47
|
|
|
39
48
|
export const convertDataToFile = async (dataToConvert: { [sheetName: string]: any[] }[]) => {
|
|
@@ -109,7 +118,7 @@ const checkData = (dataToConvert: { [sheetName: string]: IExcelDataCellWithStyle
|
|
|
109
118
|
});
|
|
110
119
|
});
|
|
111
120
|
}
|
|
112
|
-
}
|
|
121
|
+
};
|
|
113
122
|
|
|
114
123
|
export const convertDataToFileWithStyleOld = async (
|
|
115
124
|
dataToConvert: { [sheetName: string]: IExcelDataCellWithStyles[][] },
|
|
@@ -260,4 +269,23 @@ export const addHeaderToData = (header: { [key: string]: string }, data: object[
|
|
|
260
269
|
};
|
|
261
270
|
const processedItems = data.map(filterAndReorder);
|
|
262
271
|
return [header, ...processedItems];
|
|
263
|
-
}
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export const getColumnsWidths = (sheetNames: string[], columnWidth: { [columnLetter: string]: number }) => {
|
|
275
|
+
return sheetNames.reduce((acc, sheetName) => {
|
|
276
|
+
return {
|
|
277
|
+
...acc,
|
|
278
|
+
[sheetName]: columnWidth,
|
|
279
|
+
};
|
|
280
|
+
}, {});
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export const getSheetsOptions = (sheetNames: string[], options: { showGridLines: boolean }) => {
|
|
284
|
+
return sheetNames.reduce(
|
|
285
|
+
(acc, sheetName) => ({
|
|
286
|
+
...acc,
|
|
287
|
+
[sheetName]: options,
|
|
288
|
+
}),
|
|
289
|
+
{},
|
|
290
|
+
);
|
|
291
|
+
};
|