exceljs / exceljs

Excel Workbook Manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Solid fill become black

StephanMeijer opened this issue · comments

When using solid fill, the cell seems to become black entirely. It might be the case because I am using LibreOffice. Google Spreadsheets does not color the cell at all.

I recently had cause to use a solid fill myself, and no problem on it (sets an off-red background) -

cell.fill = {
	type: "pattern",
	pattern: "solid",
	fgColor: {
		argb: "FFFF7D7D"
	},
	bgColor: {
		argb: "FF000000"
	}
}

Could you have done it slightly differently? (As a side note, Excel can really mess up with fills on empty cells at the end of rows - it's ugly).

@StephanMeijer I've just published 0.4.2, which I'm hoping will resolve this issue. I've fixed an issue with handling themes which can cause the effects you're seeing.
Could you check whether this has fixed your problem?

@guyonroche I have the same issue even after updating to 0.4.2 also I am using Excel 2016 to read the output xlsx

@StephanMeijer @guyonroche I found that after setting both fgColor and bgColor to the same value I get my intended fill color with black text.

currentSheet.getRow(2).getCell(2).value = 'Test Text'; currentSheet.getRow(2).getCell(2).fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFFFFF00'}, bgColor:{argb:'FFFFFF00'} };

Will yield a yellow background with black text of "Test Text"

fgColor is the color of your filling. you only need to specify fgColor if you're using solid

this is how you fill with red color:

{
  type: 'pattern',
  pattern: 'solid',
  fgColor: { argb:'FFFF0000' }
};

I think this issue is legit as I stumbled on the proper usage of cell filling today again. I opened a PR to clarify the doc about it.
#1649