Problem with BackgroundColor and FillPattern

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
bturcs
Posts: 23
Joined: Tue Nov 14, 2017 9:28 am

Problem with BackgroundColor and FillPattern

Post by bturcs »

I'm using an indexed color and a fill pattern, but I am unable to set the pattern background color. Only the pattern foreground color is set, wich is different from XLSSUIT4.

Image

Left is the result of XLSSUIT6, right the result of XLSSUIT4. What can I do to fix this issue?

XLSSUIT Version 6:

Code: Select all

  try
    LDoc := TXLSReadWriteII5.Create(nil);
    LDoc.Sheets[0].AsString[3,3] := '';
    LFormat := LDoc.CmdFormat;
    LFormat.BeginEdit(LDoc[0]);
    LFormat.Fill.BackgroundColor.IndexColor := xcBlueGreen;
    LFormat.Fill.PatternStyle := efpLightGrid;
    LFormat.Apply(3, 3);
    LDoc.Filename := 'C:\TEMP\GRID.XLSX';
    LDoc.Write;
  finally
    freeAndNil(LDoc);
  end;
XLSSUIT Version 4:

Code: Select all

  try
    LDoc := TXLSReadWriteII4.Create(nil);
    LDoc.Sheets[0].AsString[3,3] := '';
    LCell := LDoc.Sheets[0].Cell[3,3];
    LCell.FillPatternBackColor := xcBlueGreen;
    LCell.FillPatternPattern := efpLightGrid;
    LDoc.Filename := 'C:\TEMP\GRID.XLS';
    LDoc.Write;
  finally
    freeAndNil(LDoc);
  end;


bturcs
Posts: 23
Joined: Tue Nov 14, 2017 9:28 am

Re: Problem with BackgroundColor and FillPattern

Post by bturcs »

Just solved this problem: there is a different property to set the pattern color:

Code: Select all

  try
    LDoc := TXLSReadWriteII5.Create(nil);
    LDoc.Sheets[0].AsString[3,3] := '';
    LFormat := LDoc.CmdFormat;
    LFormat.BeginEdit(LDoc[0]);
    LFormat.Fill.PatternStyle := efpLightGrid;
    LFormat.Fill.PatternColor.IndexColor := xcBlueGreen;
    LFormat.Apply(3, 3);
    LDoc.Filename := 'C:\TEMP\GRID.XLSX';
    LDoc.Write;
  finally
    freeAndNil(LDoc);
  end;
Post Reply