Open petrovi4 opened 8 years ago
Short answer, no, that's not an API feature in this branch. But if you can find a way to do that with an appropriate unit test submit a pull request!
You can set the default styles for the workbook in an object under a key of defaultCellStyle
in the write_opts
object you supply to XLSX.write
or XLSX.writeFile
.
The code which sets the default default cell styles is at xlsx.js#L12199-L12205.
var defaultStyle = options.defaultCellStyle || {}; if (!defaultStyle.font) defaultStyle.font = {name: 'Calibri', sz: '12'}; if (!defaultStyle.font.name) defaultStyle.font.name = 'Calibri'; if (!defaultStyle.font.sz) defaultStyle.font.sz = 11; if (!defaultStyle.fill) defaultStyle.fill = { patternType: "none", fgColor: {}}; if (!defaultStyle.border) defaultStyle.border = {}; if (!defaultStyle.numFmt) defaultStyle.numFmt = 0;
Here are some examples:
Has this been documented anywhere?
@toby-howell
table style (not cell style)
is it possible to do this at the table/column level? e.g. make an entire row have a background color without setting the individual cells?
It may be a part of the Office OpenXML spec and thus possible to add, but not yet part of this library.
Excel allows you to apply a style to a table (not just one cell). For example, if you apply style 9, the table filters are added, all the cells are colored automatically in accordance with that style. Can it be done in xlsx-style?