@sd.florida/excel
v1.0.16
Published
## Usage
Downloads
16
Readme
sd.florida/excel
Usage
import {
applyStyleToCell,
applyStyleToCells,
convertJSONToArrayWithStyle,
convertArrayToExcelWithStyle,
} from '@sd.florida/excel'
import type { ArrayData } from '@sd.florida/excel'
const jsonData: JSONData = [
{ 날짜: '06월 01일', 현금: 1000, 카드: 2000 },
{ 날짜: '06월 02일', 현금: 2000, 카드: 1000 },
]
// https://github.com/exceljs/exceljs#styles
const styledHeaders: HeaderStyles = {
현금: { font: { color: { argb: 'FFFF0000' } } },
카드: { fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFC0C0C0' } } },
}
const cellStyles = {
font: { color: { argb: 'FF949494' } },
}
const styledArrayData = convertJSONToArrayWithStyle(jsonData, headerStyles)
const arrayData: ArrayData = [
[
[
{
v: '병합',
s: { font: { bold: true } },
w: 15,
m: { w: 3, h: 1 },
},
],
...styledArrayData,
['06월 04일', 1000, applyStyleToCell(2000, cellStyles)],
],
]
convertArrayToExcelWithStyle(arrayData, '파일이름')