Created
April 23, 2018 23:33
-
-
Save natergj/c65206663b846ec9af52de7368c684f9 to your computer and use it in GitHub Desktop.
excel4node set background color in cell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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