UNPKG

to-spreadsheet

Version:

npm package to create spreadsheet in node environment and in browser

223 lines (222 loc) 11.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createCenteredCell = exports.createAlignedCell = exports.createVerticallyAlignedCell = exports.createHorizontallyAlignedCell = exports.createBackgroundDateCell = exports.createColoredCell = exports.createForegroundCell = exports.createBackgroundCell = exports.createBorderedDateCell = exports.createDateCell = exports.createBorderedCell = exports.createStyledCell = exports.createRightBorder = exports.createLeftBorder = exports.createBottomBorder = exports.createTopBorder = exports.createAllBorders = exports.createBorder = exports.writeEquation = exports.skipCell = exports.EnvironmentType = exports.sampleData = exports.generateExcel = exports.VerticalAlignment = exports.HorizontalAlignment = exports.BorderStyle = exports.ICellType = void 0; const generate_excel_1 = require("./generate-excel"); Object.defineProperty(exports, "generateExcel", { enumerable: true, get: function () { return generate_excel_1.generateExcel; } }); Object.defineProperty(exports, "EnvironmentType", { enumerable: true, get: function () { return generate_excel_1.EnvironmentType; } }); const util_1 = require("./util"); Object.defineProperty(exports, "skipCell", { enumerable: true, get: function () { return util_1.skipCell; } }); Object.defineProperty(exports, "writeEquation", { enumerable: true, get: function () { return util_1.writeEquation; } }); Object.defineProperty(exports, "createBorder", { enumerable: true, get: function () { return util_1.createBorder; } }); Object.defineProperty(exports, "createAllBorders", { enumerable: true, get: function () { return util_1.createAllBorders; } }); Object.defineProperty(exports, "createTopBorder", { enumerable: true, get: function () { return util_1.createTopBorder; } }); Object.defineProperty(exports, "createBottomBorder", { enumerable: true, get: function () { return util_1.createBottomBorder; } }); Object.defineProperty(exports, "createLeftBorder", { enumerable: true, get: function () { return util_1.createLeftBorder; } }); Object.defineProperty(exports, "createRightBorder", { enumerable: true, get: function () { return util_1.createRightBorder; } }); Object.defineProperty(exports, "createStyledCell", { enumerable: true, get: function () { return util_1.createStyledCell; } }); Object.defineProperty(exports, "createBorderedCell", { enumerable: true, get: function () { return util_1.createBorderedCell; } }); Object.defineProperty(exports, "createDateCell", { enumerable: true, get: function () { return util_1.createDateCell; } }); Object.defineProperty(exports, "createBorderedDateCell", { enumerable: true, get: function () { return util_1.createBorderedDateCell; } }); Object.defineProperty(exports, "createBackgroundCell", { enumerable: true, get: function () { return util_1.createBackgroundCell; } }); Object.defineProperty(exports, "createForegroundCell", { enumerable: true, get: function () { return util_1.createForegroundCell; } }); Object.defineProperty(exports, "createColoredCell", { enumerable: true, get: function () { return util_1.createColoredCell; } }); Object.defineProperty(exports, "createBackgroundDateCell", { enumerable: true, get: function () { return util_1.createBackgroundDateCell; } }); Object.defineProperty(exports, "createHorizontallyAlignedCell", { enumerable: true, get: function () { return util_1.createHorizontallyAlignedCell; } }); Object.defineProperty(exports, "createVerticallyAlignedCell", { enumerable: true, get: function () { return util_1.createVerticallyAlignedCell; } }); Object.defineProperty(exports, "createAlignedCell", { enumerable: true, get: function () { return util_1.createAlignedCell; } }); Object.defineProperty(exports, "createCenteredCell", { enumerable: true, get: function () { return util_1.createCenteredCell; } }); var ICellType; (function (ICellType) { ICellType["string"] = "s"; ICellType["number"] = "n"; ICellType["date"] = "d"; ICellType["skip"] = "skip"; ICellType["equation"] = "equation"; })(ICellType || (ICellType = {})); exports.ICellType = ICellType; var BorderStyle; (function (BorderStyle) { BorderStyle["none"] = "none"; BorderStyle["thin"] = "thin"; BorderStyle["medium"] = "medium"; BorderStyle["thick"] = "thick"; BorderStyle["double"] = "double"; BorderStyle["dotted"] = "dotted"; BorderStyle["dashed"] = "dashed"; })(BorderStyle || (BorderStyle = {})); exports.BorderStyle = BorderStyle; var HorizontalAlignment; (function (HorizontalAlignment) { HorizontalAlignment["general"] = "general"; HorizontalAlignment["left"] = "left"; HorizontalAlignment["center"] = "center"; HorizontalAlignment["right"] = "right"; HorizontalAlignment["fill"] = "fill"; HorizontalAlignment["justify"] = "justify"; HorizontalAlignment["centerContinuous"] = "centerContinuous"; HorizontalAlignment["distributed"] = "distributed"; })(HorizontalAlignment || (HorizontalAlignment = {})); exports.HorizontalAlignment = HorizontalAlignment; var VerticalAlignment; (function (VerticalAlignment) { VerticalAlignment["top"] = "top"; VerticalAlignment["center"] = "center"; VerticalAlignment["bottom"] = "bottom"; VerticalAlignment["justify"] = "justify"; VerticalAlignment["distributed"] = "distributed"; })(VerticalAlignment || (VerticalAlignment = {})); exports.VerticalAlignment = VerticalAlignment; const sampleData = [ { title: 'Maifee1', content: [ ['meaw', 'grrr'], ['woof', 'smack'], [1], [1, 2], [1, 2, 3, (0, util_1.writeEquation)('SUM(A5,C5)')], ] }, { title: 'Maifee2', content: [[1], [1, (0, util_1.skipCell)(3), 2]] }, { title: 'Maifee3', content: [['meaw', undefined, "meaw"], ["woof", 'woof']] }, { title: 'BorderDemo', content: [ [ (0, util_1.createBorderedCell)('Product', (0, util_1.createAllBorders)(BorderStyle.thick, '#000000')), (0, util_1.createBorderedCell)('Price', (0, util_1.createAllBorders)(BorderStyle.thick, '#000000')), (0, util_1.createBorderedCell)('Total', (0, util_1.createAllBorders)(BorderStyle.thick, '#000000')) ], [ (0, util_1.createBorderedCell)('Apple', (0, util_1.createLeftBorder)()), (0, util_1.createBorderedCell)(10, (0, util_1.createTopBorder)()), (0, util_1.createBorderedCell)(100, (0, util_1.createRightBorder)()) ], [ (0, util_1.createStyledCell)('Custom', { border: { left: BorderStyle.double, bottom: BorderStyle.thin, color: '#0000FF' } }), 200, 'No Border Cell' ] ] }, { title: 'DateDemo', content: [ [ 'Event', 'Date', 'Bordered Date' ], [ 'Project Start', (0, util_1.createDateCell)(new Date('2024-01-01')), (0, util_1.createBorderedDateCell)(new Date('2024-01-15'), (0, util_1.createAllBorders)(BorderStyle.thin, '#000000')) ], [ 'Milestone 1', (0, util_1.createDateCell)(new Date()), (0, util_1.createDateCell)(new Date('2024-12-31')) ], [ 'Custom Date Style', (0, util_1.createDateCell)(new Date('2024-06-15'), { border: { top: BorderStyle.thick, bottom: BorderStyle.double, color: '#FF0000' } }), 'Mixed Content' ] ] }, { title: 'ColorDemo', content: [ [ 'Feature', 'Background Color', 'Foreground Color', 'Both Colors' ], [ 'Yellow Background', (0, util_1.createBackgroundCell)('Highlighted', '#FFFF00'), (0, util_1.createForegroundCell)('Red Text', '#FF0000'), (0, util_1.createColoredCell)('Both', '#00FF00', '#FF0000') ], [ 'More Colors', (0, util_1.createBackgroundCell)('Blue BG', '#0000FF'), (0, util_1.createForegroundCell)('Green Text', '#00FF00'), (0, util_1.createColoredCell)('Purple/White', '#800080', '#FFFFFF') ], [ 'Date Colors', (0, util_1.createBackgroundDateCell)(new Date(), '#FFCCCC'), (0, util_1.createDateCell)(new Date('2024-12-25'), { backgroundColor: '#00FF00', foregroundColor: '#FF0000' }), 'Mixed with dates' ], [ 'With Borders', (0, util_1.createStyledCell)('Complex', { backgroundColor: '#FFFFCC', foregroundColor: '#0000FF', border: (0, util_1.createAllBorders)(BorderStyle.thick, '#000000') }), 'Plain text', 42 ] ] }, { title: 'AlignmentDemo', content: [ [ 'Feature', 'Horizontal Alignment', 'Vertical Alignment', 'Both Alignments' ], [ 'Left Align', (0, util_1.createHorizontallyAlignedCell)('Left Text', HorizontalAlignment.left), (0, util_1.createVerticallyAlignedCell)('Top Text', VerticalAlignment.top), (0, util_1.createAlignedCell)('Top-Left', HorizontalAlignment.left, VerticalAlignment.top) ], [ 'Center Align', (0, util_1.createHorizontallyAlignedCell)('Center Text', HorizontalAlignment.center), (0, util_1.createVerticallyAlignedCell)('Center Text', VerticalAlignment.center), (0, util_1.createCenteredCell)('Full Center') ], [ 'Right Align', (0, util_1.createHorizontallyAlignedCell)('Right Text', HorizontalAlignment.right), (0, util_1.createVerticallyAlignedCell)('Bottom Text', VerticalAlignment.bottom), (0, util_1.createAlignedCell)('Bottom-Right', HorizontalAlignment.right, VerticalAlignment.bottom) ], [ 'Complex Style', (0, util_1.createStyledCell)('All Features', { horizontalAlignment: HorizontalAlignment.center, verticalAlignment: VerticalAlignment.center, backgroundColor: '#CCFFCC', foregroundColor: '#FF0000', border: (0, util_1.createAllBorders)(BorderStyle.thick, '#000000') }), (0, util_1.createAlignedCell)(new Date(), HorizontalAlignment.right, VerticalAlignment.center), (0, util_1.createCenteredCell)(42) ] ] } ]; exports.sampleData = sampleData;