Skip to content

Instantly share code, notes, and snippets.

@natergj
Created April 23, 2018 23:33
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natergj/c65206663b846ec9af52de7368c684f9 to your computer and use it in GitHub Desktop.
Save natergj/c65206663b846ec9af52de7368c684f9 to your computer and use it in GitHub Desktop.
excel4node set background color in cell
// Require library
const xl = require('excel4node');
// Create a new instance of a Workbook class
const wb = new xl.Workbook();
// Add Worksheets to the workbook
const ws = wb.addWorksheet('Background Color');
// create a style with solid background color
// for "solid" pattern, the fgcolor is the color shown
const bgStyle = wb.createStyle({
fill: {
type: 'pattern',
patternType: 'solid',
bgColor: '#FFFF00',
fgColor: '#FFFF00',
}
});
ws.cell(1, 1).style(bgStyle);
ws.cell(1, 1).string('Yellow');
wb.write('BG_Color.xlsx');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment