diff --git a/src/utils/excelConverter.ts b/src/utils/excelConverter.ts index 73a3597..4517866 100644 --- a/src/utils/excelConverter.ts +++ b/src/utils/excelConverter.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { Workbook } from "exceljs"; +import { Borders, Workbook } from "exceljs"; import { convertThemeColorToRGB, rgbToHex } from "./excelColors"; import { CellData, CellStyle, RowData, SheetData } from "x-data-spreadsheet"; @@ -11,9 +11,19 @@ declare module "x-data-spreadsheet" { } +type borderDir = "top"|"bottom"|"left"|"right"; export function toSpreadsheet(wb: Workbook) { + function mapColor(oStyle: CellStyle,border: Partial, what: borderDir){ + if(border[what] && border[what].style && oStyle.border){ + oStyle.border[what] = [ + border[what].style?.toString(), + "#" + getColor(border[what].color) + ] + } + } + console.log(wb); const out = wb.worksheets.map((ws) => { @@ -75,7 +85,21 @@ export function toSpreadsheet(wb: Workbook) { } if (cell.style.border) { - // + + + + const border = cell.style.border; + console.log(border) + oStyle.border = {}; + ["top","bottom","left","right"].forEach(what=>{ + mapColor(oStyle,border,what as borderDir); + }) + // if(border.bottom && border.bottom.style){ + // oStyle.border.bottom = [ + // border.bottom.style?.toString(), + // "#" + getColor(border.bottom.color) + // ] + // } } if (cell.style.font) { const font = cell.style.font;