# Styling

## Font

```js
var XLSX = require('xlsx');
// If each key in font is omitted, Excel applies the default value
var font = {
    sz: { val: 11 },
    color: { rgb: 'FFRRGGBB'},
    name: { val: 'Calibri' }
}
// Cell address is 0-indexed
XLSX.utils.set_font(workbook, worksheet, {c: 0, r: 0}, font);
```

## Fill

```js
var XLSX = require('xlsx');
// bgColor applies to a pattern, except solid
var fill = {
    patternType: 'solid',
    fgColor: { rgb: 'FFRRGGBB' },
    bgColor: { rgb: 'FFRRGGBB' }
}
// Cell address is 0-indexed
XLSX.utils.set_fill(workbook, worksheet, {c: 0, r: 0}, fill);
```

Patterns supported by Excel

[![](styling_fill.png)](styling_fill.png)

## Border

```js
var XLSX = require('xlsx');
// diagonalUp/Down: whether to draw diagonal border going up/down right or not
// If diagonal is omitted, no diagonal border is visible
// If each of top, bottom, left, right: whether to draw each border
var border = {
    diagonalUp: 1,
    diagonalDown: 1,
    top: {
        style: 'thin',
        color: { rgb: 'FFRRGGBB' }
    },
    bottom: {
        style: 'thin',
        color: { rgb: 'FFRRGGBB' }
    },
    left: {
        style: 'thin',
        color: { rgb: 'FFRRGGBB' }
    },
    right: {
        style: 'thin',
        color: { rgb: 'FFRRGGBB' }
    },
    diagonal: {
        style: 'thin',
        color: { rgb: 'FFRRGGBB' }
    },
}
// Cell address is 0-indexed
XLSX.utils.set_font(workbook, worksheet, {c: 0, r: 0}, font);
```
