UNPKG

to-spreadsheet

Version:

npm package to create spreadsheet in node environment and in browser

105 lines (104 loc) 3.28 kB
import { generateExcel, EnvironmentType } from "./generate-excel"; import { SkipCell, skipCell, Equation, writeEquation, createBorder, createAllBorders, createTopBorder, createBottomBorder, createLeftBorder, createRightBorder, createStyledCell, createBorderedCell, createDateCell, createBorderedDateCell, createBackgroundCell, createForegroundCell, createColoredCell, createBackgroundDateCell, createHorizontallyAlignedCell, createVerticallyAlignedCell, createAlignedCell, createCenteredCell } from "./util"; declare enum ICellType { string = "s", number = "n", date = "d", skip = "skip", equation = "equation" } declare enum BorderStyle { none = "none", thin = "thin", medium = "medium", thick = "thick", double = "double", dotted = "dotted", dashed = "dashed" } declare enum HorizontalAlignment { general = "general", left = "left", center = "center", right = "right", fill = "fill", justify = "justify", centerContinuous = "centerContinuous", distributed = "distributed" } declare enum VerticalAlignment { top = "top", center = "center", bottom = "bottom", justify = "justify", distributed = "distributed" } interface IBorder { top?: BorderStyle; right?: BorderStyle; bottom?: BorderStyle; left?: BorderStyle; color?: string; } interface ICellStyle { border?: IBorder; backgroundColor?: string; foregroundColor?: string; horizontalAlignment?: HorizontalAlignment; verticalAlignment?: VerticalAlignment; } interface ICellString { type: ICellType.string; value: number; style?: ICellStyle; } interface ICellNumber { type: ICellType.number; value: number; style?: ICellStyle; } interface ICellSkip { type: ICellType.skip; } interface ICellEquation { type: ICellType.equation; value: Equation; style?: ICellStyle; } interface ICellDate { type: ICellType.date; value: Date; style?: ICellStyle; } declare type ICell = ICellString | ICellNumber | ICellDate | ICellSkip | ICellEquation; interface IRows { cells: ICell[]; } interface ISheet { title: string; rows: IRows[]; } interface IWorkbook { filename: string; sheets: ISheet[]; strings: string[]; } interface IPage { title: string; content: (string | number | undefined | SkipCell | Equation | ICell)[][]; } export { ICell, ISheet, IWorkbook, IRows, ICellType, IPage, BorderStyle, IBorder, ICellStyle, ICellDate, HorizontalAlignment, VerticalAlignment }; declare const sampleData: ({ title: string; content: (string[] | (number | Equation)[])[]; } | { title: string; content: (number | SkipCell)[][]; } | { title: string; content: (string | undefined)[][]; } | { title: string; content: (string | number | ICell)[][]; })[]; export { generateExcel, sampleData, EnvironmentType, skipCell, writeEquation, createBorder, createAllBorders, createTopBorder, createBottomBorder, createLeftBorder, createRightBorder, createStyledCell, createBorderedCell, createDateCell, createBorderedDateCell, createBackgroundCell, createForegroundCell, createColoredCell, createBackgroundDateCell, createHorizontallyAlignedCell, createVerticallyAlignedCell, createAlignedCell, createCenteredCell };