I would like to set style for range ...(A1:D10).style.....
I have written this little function that styles certain columns of a row, I suppose you can easily extend it.
var cell;
var styleColumnsInRow = function(row, keys, styles){
_.each(keys, function(key){
cell = row.getCell(key);
_.each(styles, function(style){
cell[style.key] = style.value;
});
});
};
You can call it like that:
var row = sheet.getRow(1);
var columns = ['amount','price','color'];
var styles = [{key: 'border', value: {bottom: {style: 'double'}}}];
styleColumnsInRow(row, columns, styles);
That will give the three columns double border in the bottom.
Here is how I've apply style to range:
['A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1'].map(key => {
sheet.getCell(key).fill = {
type: 'pattern',
pattern:'solid',
fgColor:{argb:'cccccc'}
};
});
Most helpful comment
Here is how I've apply style to range: