Picture placement in a cell
-
- Posts: 19
- Joined: Mon Aug 20, 2012 10:22 pm
Picture placement in a cell
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
Thanks,
Marshall Thomas
Re: Picture placement in a cell
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.
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.
Lars Arvidsson, Axolot Data
-
- Posts: 19
- Joined: Mon Aug 20, 2012 10:22 pm
Re: Picture placement in a cell
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
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
Hello
The row and column offset values are percent of the width. They can't be negative, values must be between zero and one.
The row and column offset values are percent of the width. They can't be negative, values must be between zero and one.
Lars Arvidsson, Axolot Data
-
- Posts: 19
- Joined: Mon Aug 20, 2012 10:22 pm
Re: Picture placement in a cell
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
Marshall
Re: Picture placement in a cell
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.
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.
Lars Arvidsson, Axolot Data
-
- Posts: 19
- Joined: Mon Aug 20, 2012 10:22 pm
Re: Picture placement in a cell
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
Marshall
-
- Posts: 19
- Joined: Mon Aug 20, 2012 10:22 pm
Re: Picture placement in a cell
Is there a way to programmatically change the height and width of a picture after it has been inserted?
Marshall
Marshall
Re: Picture placement in a cell
Hello
Yes. Example:
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;
Lars Arvidsson, Axolot Data
-
- Posts: 19
- Joined: Mon Aug 20, 2012 10:22 pm
Re: Picture placement in a cell
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
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
-
- Posts: 19
- Joined: Mon Aug 20, 2012 10:22 pm
Re: Picture placement in a cell
Could someone please explain how to use EditImage?
Thanks,
Marshall
Thanks,
Marshall
Re: Picture placement in a cell
Hello
Please take a look at the source code for more details.
Please take a look at the source code for more details.
Lars Arvidsson, Axolot Data
-
- Posts: 19
- Joined: Mon Aug 20, 2012 10:22 pm
Re: Picture placement in a cell
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
Sorry to be such a bother,
Marshall
-
- Posts: 19
- Joined: Mon Aug 20, 2012 10:22 pm
Re: Picture placement in a cell
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
Thanks for your help,
Marshall Thomas