Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set cell backgrounds by createStyle not working #88

Open
lRoberth opened this issue Nov 17, 2023 · 1 comment
Open

Set cell backgrounds by createStyle not working #88

lRoberth opened this issue Nov 17, 2023 · 1 comment

Comments

@lRoberth
Copy link

Describe the bug
Set cell backgrounds by createStyle not working

To Reproduce
Run next code
`var style = workbook.createStyle({
font: {
color: '#FF0800',
size: 12
},
numberFormat: '$#,##0.00; ($#,##0.00); -'
});

var style2 = workbook.createStyle({
fill: {
type: 'pattern',
pattern: 'solid',
fgColor: '#f20202', // Foreground color
bgColor: '#f20202', // Background color
},
font: {
color: '#10c8c8',
size: 10,
}
});

worksheet2.cell(1,1).string("#").style(style2);
worksheet2.cell(1,2).string("Full Legal Name").style(style);
worksheet2.cell(1,3).string("Job Title").style(style2);
worksheet2.cell(1,4).string("Market").style(style2);
worksheet2.cell(1,5).string("Location Type").style(style2);
worksheet2.cell(1,6).string("Termination Date").style(style2);

workbook.write('Excel.xlsx');`

This will not apply red colors to the cell at style2, it keeps it white.

Expected behavior
Color should be applied to cell

Environment (please complete the following information):

  • OS: macOS Sonoma 14.1.1
  • Node Version: v20.9.0
  • excel4node Version: 1.8.2
  • Application: Office 365
  • Application Version (if applicable): Excel 16.79.23111614

Additional context
There are no environment errors

@Devidian
Copy link

I had a similar problem, but my cells used to stay black. I was looking for a reason and found this issue. Then i realized i missed to add fgColor to my style. I also see the problem in your case. It yould be patternType: 'solid' not just pattern. You might have solved this old issue i just wanted to note for any other that might stumble over it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants