Page 1 of 1

Cell background color is not set using DefaultFormat

Posted: Fri Mar 09, 2018 8:23 am
by coheris
Hello !

I'm using XLSReadWriteII 6.32 to create a XLS file ('97).
I use XLS.CmdFormat to create a default format.

In this default format, I define some properties about Alignment, Font, Border, and Fill.
In my case, I set the cell background color like this (please tell me if I'm wrong, I read that only RGB property is used in the FormatCells Sample to set background, does it mean IndexColor is not recommended ?) :

Code: Select all

XLS.CmdFormat.Fill.BackgroundColor.IndexColor := _format.FillPatternBackColor;
Then I add as default the format :

Code: Select all

XLS.CmdFormat.AddAsDefault('F' + IntToStr(formatCount));
Finally, I write in my cell with the required format like this :

Code: Select all

XLS.DefaultFormat := XLS.CmdFormat.Defaults.Find('F' + IntToStr(_fmtIdx));
XLS[curSheet].AsFloat[_col, _row] := _number;
And when I open my document, everything is fine about alignment, font, and border, but my background color is not set.

Thank you and best regards.

Re: Cell background color is not set using DefaultFormat

Posted: Tue Mar 20, 2018 4:13 pm
by coheris
Hi,

Do you have any news about this issue ?

Best regards.

Re: Cell background color is not set using DefaultFormat

Posted: Wed Mar 21, 2018 9:02 am
by larsa
Hello

No, I can't reproduce this. Here is the code I used:

Code: Select all

XLS.CmdFormat.BeginEdit(FXSS.XLS[0]);
XLS.CmdFormat.Fill.BackgroundColor.IndexColor := xcBlue;
XLS.CmdFormat.AddAsDefault('F1');

XLS.DefaultFormat := FXSS.XLS.CmdFormat.Defaults.Find('F1');
XLS[0].AsFloat[1,1] := 125
Please include code samples that will compile. It's then much easier to see what may be wrong.

Re: Cell background color is not set using DefaultFormat

Posted: Wed Mar 21, 2018 10:32 am
by coheris
Hi !

I've now been able to fix the issue (which was ours :) )
I don't know how or why, but with XLSRWII 6, what was considered as FillPatternForeColor in our application is now the FillPatternBackgroundColor.
So obviously the background color wasn't set as I didn't update the right property...

Thank you and best regards.