EhLib.Com
https://forum.ehlib.com/en/

Error on Export to Excel
https://forum.ehlib.com/en/viewtopic.php?f=5&t=1098
Page 3 of 3

Author:  blumache [ 13 Mar 2023, 10:31 ]
Post subject:  Re: Error on Export to Excel

blumache wrote:
About Excel XLSX export. It is possible to export the color of the ehlib grid cells? :roll:


Thanks for reply. I need a solution to export a grid with cells colored different, using different condition.

I try your ehlib demos examples to change the color of the font from different cells in red if the condition is true.

grid->Canvas->Font->Color = clRed;
grid->DefaultDrawColumnCell(Rect, DataCol, Column, State);

On the screen looks ok, no problem. But in XLSX export, i don't see red font form desktop, only blue font in all xlsx.

Some advice, please!

Author:  EhLibSupport [ 14 Mar 2023, 10:02 ]
Post subject:  Re: Error on Export to Excel

Hello

Use TDBGridEh.OnGetColumnCellParams or TColumnEh.OnGetCellParams to set background or font color like this:

Code:
procedure TForm1.DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh;
  AFont: TFont; var Background: TColor; State: TGridDrawState);
begin
  if MemTableEh1.FieldByName('Continent').AsString = 'North America' then
  begin
    //Background := clMoneyGreen;
    AFont.Color := clRed;
  end;
end;


Grid uses OnGetCellParams event when draw cells and when export itself.

Page 3 of 3 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/