Page 1 of 1

Picture placement in a cell

Posted: Fri Aug 30, 2013 5:38 pm
by deadballfan
I create a spreadsheet for a client that displays a product picture in one of the columns. This works great but he wants to be able to sort the spreadsheet and keep the pictures with the data. I have already set the positional property of the picture to "move and size". I have found that this won't work unless the picture does not touch any of the cell's borders, but no matter what I try, the picture always touches the right hand and bottom borders. Row2Offs and Col2Offs do not seem to have any effect on this. What can I try?

Thanks,
Marshall Thomas

Re: Picture placement in a cell

Posted: Mon Sep 02, 2013 7:01 am
by larsa
Hello

I can't reproduce this. Have you tested with the Picture sample?
Change the line in the btnAdd1Click procedure to this:
XLS[0].Drawing.InsertImage(edImageFile.Text,seCol.Value - 1,seRow.Value,0.5,0.5,1.25);

And the picture will be offseted to half cells.

Re: Picture placement in a cell

Posted: Thu Sep 05, 2013 3:51 pm
by deadballfan
Thanks, but this isn't quite what I need. I need to have the picture (and these are somewhat large pictures) shrink down to a size that fits the overall spreadsheet. I am increasing the height and width of the respective cells, but in order to keep the picture within say Column 0, Row 1 I have to use something like this:

PicImage := XLS1.Sheets[0].Drawing.InsertImage(sPicfile,0,iRow,0.1,0.1,0.10);
PicImage.Row2 := iRow+1;
PicImage.Row2Offs := -1; //changed from zero
PicImage.Col2 := 1;
picImage.Col2Offs := -1; // changed from zero
picimage.Positioning := doipMoveAndSize;

The Row2Offs and Col2Offs do not work (positive numbers do, but that's not what I need).

Marshall

Re: Picture placement in a cell

Posted: Fri Sep 06, 2013 2:09 pm
by larsa
Hello

The row and column offset values are percent of the width. They can't be negative, values must be between zero and one.

Re: Picture placement in a cell

Posted: Fri Sep 06, 2013 2:54 pm
by deadballfan
Positive numbers always make the picture offsets on the right and bottom cross the cell borders. I need the picture to fall just short of the right and bottom sides.

Marshall

Re: Picture placement in a cell

Posted: Mon Sep 09, 2013 6:46 pm
by larsa
Hello

I don't think I understand... Why can't you just place the picture in the cells where you want it? You can then finetune the placement with ColOffs and RowOffs.

Re: Picture placement in a cell

Posted: Tue Sep 10, 2013 6:25 am
by deadballfan
First, the picture is always larger than the cell. I place the picture in the cell using col offset and row offset. No problem with keeping the photo from touching the left cell border or the top cell border. But the picture always touches the right cell border and the bottom cell border. If I then make the cell wider or taller, the picture continues to follow the cell borders and still touches the right cell border and the bottom cell border. Is there a way to tell the picture to shrink a few pixels in width or height?

Marshall

Re: Picture placement in a cell

Posted: Wed Sep 18, 2013 3:42 am
by deadballfan
Is there a way to programmatically change the height and width of a picture after it has been inserted?

Marshall

Re: Picture placement in a cell

Posted: Wed Sep 18, 2013 11:24 am
by larsa
Hello

Yes. Example:

Code: Select all

var
  MyImage: TXLSDrawingImage;
begin
  MyImage := FXSS.XLS[0].Drawing.Images[0];
  EdImage := XLS.Drawing.EditImage(MyImage);
  try
    // Shrink the picture by 50%
    EdImage.Scale(0.5);
  finally
    EdImage.Free;
  end;
end;

Re: Picture placement in a cell

Posted: Fri Sep 20, 2013 10:41 pm
by deadballfan
Sorry, but I'm having a problem getting this to compile:

var
PicImage: TXLSDrawingImage;
EdImage : TXlsDrawingEditor;
iRow : integer;
sPicfile : string;
begin
iRow := 1;
sPicfile := 'test.jpg';
PicImage := XLS1.Sheets[0].Drawing.InsertImage(sPicfile,0,iRow,0.1,0.1,0.10);
EdImage := XLS1.Sheets[0].Drawing.EditImage(PicImage);
try
// Shrink the picture by 50%
EdImage.Scale(0.5);
finally
EdImage.Free;
end;
end;

I cannot find a reference to EditImage in the help files.

Thanks for your help,
Marshall

Re: Picture placement in a cell

Posted: Thu Oct 03, 2013 8:08 pm
by deadballfan
Could someone please explain how to use EditImage?

Thanks,
Marshall

Re: Picture placement in a cell

Posted: Wed Oct 09, 2013 6:20 am
by larsa
Hello

Please take a look at the source code for more details.

Re: Picture placement in a cell

Posted: Wed Oct 09, 2013 6:35 am
by deadballfan
If you are referring to the source code above, I was unable to get it to compile. Perhaps I'm missing something.

Sorry to be such a bother,
Marshall

Re: Picture placement in a cell

Posted: Tue Oct 29, 2013 3:01 pm
by deadballfan
Totally my fault. I had a bad installation and didn't realize it. Lars' response was spot on. I can now sort the pictures along with the rest of the data.

Thanks for your help,
Marshall Thomas