Sorry to say George that I have not encountered this specific problem but do
wonder if it is related to the type of client anchor that HSSF uses. These
anchors seem to tie an image to a specific cell whereas using Excel itself,
it is possible to identify the coordinates of the images corners along with
inset values also. Tying the image directly to the cell means that when the
cell is re-sized then so is the image and I think that this is what is
happening in your case - changing the size of the default font causes Excel
to increase the width and height of the sheets cells when it opens the
worksheet. Sorry to say that I cannot think of an easy answer because Excel
is resizing the columns rather than POI but if it helps you could take a
look at some code I wrote quite some time ago. It allows you to add an image
onto a sheet and to specify the location of the image and its' dimensions.
you can find it all here;
http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java?revision=805284&view=markup

Do not know if it will work for your requirement and it certainly does not
answer your question but you may be able to use this class to get you over
the current problem.

Yours

Mark B


George Wei wrote:
> 
> There are no comments from neither developers nor users for several days.
> Hasn't anybody encountered this problem except me?
> 
> 
> George Wei wrote:
>> 
>> Dear all,
>> 
>> As my test result, this function only works when the default font size of
>> workbook not changed. If I modified its size (For example, from 12 to 22)
>> and then call this function to insert an image, it stretchs horizontally.
>> 
>> Image 1 (Default font size set to 12):
>>  http://old.nabble.com/file/p26738706/1.jpg 
>> 
>> Image 2 (Default font size set to 22):
>>  http://old.nabble.com/file/p26738706/2.jpg 
>> 
>> I've checked the source code of HSSFPicture.java, function resize() calls
>> another function getPixelWidth() to calculate the column width in pixels,
>> but the later function only works correctly when the default font size of
>> workbook not changed.
>> 
>> Can somebody give me some suggestions to correct this problem? Thanks.
>> 
>> George
>> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Bug-of-HSSFPicture.resize%28%29-tp26738706p26855152.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to