Inserting Pictures


#1

How do I insert a picture into a cell and have it resize according to the actual size of the picture and not come out distorted? The end-customer will be allowed to use their own picture - so the size of the pictures can vary.


#2

Please try:

pictures.Add(10, 10, "d:\\logo.jpg");


#3

The problem there is - the picture doesnt seem to be constrained to a single cell.. If the customer puts in a large logo - then it could overlap the data..

Is there another way?


#4

If you want to put a logo into a single cell, please try:

1. Adjust row height and column width of that cell

2. Use the following code to resize picutures:

pictures.Add(10, 10, "d:\\logo.jpg", 50, 50);


#5

Sleight misunderstanding there - I dont want to resize the picture - but the cell to fit the picture whatever the size.. How do those sizes (the picture size to the cell size) correspond? I am assuming it's not a 1 to 1 ratio.


#6

I can provide two method to allow you set column width and row height in unit of pixels. Then you can set the cell size according to picture size.


#7

That would be great - alternatively you could just give me the calculation if thats easier.

But whatever you deem best is fine. Thanks for your help.


#8

Please try this attached fix.

///


/// Sets row height in unit of pixels.
///

/// Row index.
/// Number of pixels.
public void SetRowHeightPixel(int row, int pixels)

///


/// Sets column width in unit of pixels.
///

/// Column index.
/// Number of pixels.
public void SetColumnWidthPixel(int column, int pixel)


#9

At the moment I am having some issues with my PC. Hopefully I will be able to test this by Monday - I'll let you know how it goes. Again - thanks for your help and the prompt turnaround.


#10

Is this fix in a newer version of
Aspose.Cells? While the powers that be
are talking about the licensing thing I am forging ahead with 3.6.2.0 at the
moment. I want to insert a table and
chart with an image below it, and then possibly repeat the same for another
item. I am completely happy with making
the cell(s) under the pic being the size of the pic in pixels as I don’t want
to resize the image. Of course I am just
as happy if there is a way I can tell in which row the image ends. If it is not in a newer version can you send
me the code in a dll or text form so I can resize the cells. I noticed you sent Aspose.Cells.dll in the
forum, and I don’t want to overwrite the one I have because of version issues.


#11

Currently we don’t provide a way to know the end row of image because it may change after you adjust the row height.