Change the background of a cell comment

Hi,

How can i add an image as the background of a cell comment ?
If i use APIMate, it's not creating the background image, and it's just showing how to create the comment.

I guess it's something related to ShapeFill property from ICommentProperties withTBlipFill_Create and TBlip_Create, but i can't make it work, is there any sample code to do this ?

Thanks,
Matthieu

Hi,
For xls files, you can set the comment background with code similar to the code below. But image backgrounds for comments are not yet supported in xlsx. I've added to look into supporting xlsx image backgrouns for comments into the todo list.


var
  PicData: ByteArray;
  CommentProps:ICommentProperties;
  xls: TExcelFile;  
begin
xls := TXlsFile.Create(1, true);
try
  PicData := TFile.ReadAllBytes('r:\test.png');
  CommentProps := TCommentProperties_CreateStandard(1, 1, xls);
  CommentProps.ShapeFill := TShapeFill_Create(true, TBlipFill_Create(96, false,
    TBlip_Create(TBlipCompression.Print, PicData, '', 'image/png'), Nullable<TDrawingRelativeRect>.Null, TBlipFillStretch.Create(TDrawingRelativeRect.Create())));
  xls.SetComment(1, 1, 'hello', 'adrian', CommentProps);
  xls.Save('r:\test.xls');
finally
  xls.Free;
end;




Note
: I am not sure why, but it seems that we forgot to add TBlipFill_Create method to the functions exported by VCL.FlexCel.Core. So to make the code above compile, you will have to explicitly add _UThemes.TBlipFill, to the uses clause. For the next version to be released next week this should be fixed and you won't need to add this unit to the uses.

Thank you.

Matthieu