Yes, of course I will but it will not be what I thought.

Rain forced us off of site and one of my colleagues has taken the volunteers
to the tree nursery. As a result, I have had the time to play with some code
and found that the image settings from the sheet are ignored by Excel; the
image is resized just as before and so this technique will not work.

What may though is making use of the first four parameters passed to the
HSSFClientAnchor class. So far, I have found that they can be used to affect
the size of the image on the sheet and overcome the automatic expansion when
Excel sets the columns width. Therefore, I am working on finding an
algorithm that will allow me to take the size of the expanded column and
work back from that to the desired size of the image. Knowing that, I can
then work out how to set these parameters values so that the image is
correctly sized.

Will post again as soon as I make some progress.

Yours

Mark B


deep4u wrote:
> 
> Hi mark,
>             when u free send me the code.
> 
> Thanks,
> 
> MSB wrote:
>> 
>> The image ought to be fine. Using Excel, it is possible to set the same
>> sort of properties that you can with POI, i.e. that the image should not
>> move or resize itself with the cells. To do this using 'my' version of
>> Excel, you select the image on the worksheet and click on the right hand
>> mouse button; this pops open a menu from which you can select the 'Size
>> and Properties' option. The options screen that appears in response to
>> this has a number of tabs on it. One of them is labelled 'Properties' and
>> selecting this allows you to say how the image should respond to resizing
>> of the cells. I would select the 'Don't move or size with cells' option.
>> Then the image ought to remain tha same size irrespective of what you do
>> with the columns or rows.
>> 
>> If you are in no hurry, I can put together some code later today to test
>> this hypothesis and then post the results to you. Sadly, I have to leave
>> in about an hour to help a group of volunteers construct a flight of
>> steps linking two footpaths together - which should be fun given the
>> weather forecast today - but should be able to get some code together
>> this evening.
>> 
>> Yours
>> 
>> Mark B
>> 
>> 
>> deep4u wrote:
>>> 
>>> Hi mark,
>>>             I need to create a excel dynamically means based On weekly,
>>> Monthly, suppose this is current week so 07/24/09-07/31/09,...next based
>>> on months  july month the name excelsheet will be "july.xls" , and next
>>> nonth "August.xls"... If i taking a template ok but in my program i will
>>> set autosize on that no streched the image?
>>> 
>>> Thanks,
>>> 
>>> 
>>> MSB wrote:
>>>> 
>>>> You need to do the following;
>>>> 
>>>> Start Excel
>>>> If necessary, open a new workbook - Excel usually opens up with a new,
>>>> empty workbook so this may not be necessary.
>>>> Select Insert->Picture and navigate your way to where the logo image is
>>>> stored. Select (highlight) the image and then click on the Insert
>>>> button.
>>>> Now, you should see that the logo has been inserted into the worksheet
>>>> and you can use the mouse to drag it into the correct location and
>>>> re-size it as necessary.
>>>> Save the file away and remember where you stored it and the name you
>>>> used.
>>>> 
>>>> That has created the template that you will pick up using POI and
>>>> populate with data. All you need to do is something like this;
>>>> 
>>>> File file = new File("..Path to and name of the file you created
>>>> above..");
>>>> FileInputStream fis = new FileInputStream(file);
>>>> HSSFWorkbook workbook = new HSSFWorkbook(fis);
>>>> HSSFSheet sheet = workbook.getSheetAt(0);
>>>> 
>>>> and when you have your sheet, populate it in the usual manner and then
>>>> save the completed workbook away again, most likely using a different
>>>> name so that the template can be used again and again as the basis for
>>>> further documents. It is common to see users do this sort of thing as
>>>> POI's image manipulation facilities are not quite as feature rich as
>>>> are Excel's.
>>>> 
>>>> Hope that helps. If it is not clear, I will create a template and some
>>>> code that picks it up and populates it and PM both to you; just let me
>>>> know.
>>>> 
>>>> Yours
>>>> 
>>>> Mark B
>>>> 
>>>> 
>>>> deep4u wrote:
>>>>> 
>>>>> Hi mark,
>>>>>            I need to create Excel sheet dynamically with logo. But
>>>>> using Template how it is possible.
>>>>> 
>>>>> Thanks,
>>>>> 
>>>>> 
>>>>> MSB wrote:
>>>>>> 
>>>>>> So, setting the anchor type does not solve the problem?
>>>>>> 
>>>>>> In that case, I think that your only recourse is to create a document
>>>>>> template using Excel and to place the logo onto the document with it.
>>>>>> Then you should be able to safely use HSSF/XSSF to populate the
>>>>>> worksheet.
>>>>>> 
>>>>>> Yours
>>>>>> 
>>>>>> Mark B
>>>>>> 
>>>>>> 
>>>>>> deep4u wrote:
>>>>>>> 
>>>>>>> Hi,
>>>>>>>     i use the poi 3.5 also image will be expanding. I write like
>>>>>>> this
>>>>>>>  anchor.setAnchorType(HSSFClientAnchor.DONT_MOVE_AND_RESIZE);
>>>>>>> or  anchor.setAnchorType(3);  how to reslove this.
>>>>>>> 
>>>>>>> Thanks,
>>>>>>> 
>>>>>>> 
>>>>>>> deep4u wrote:
>>>>>>>> 
>>>>>>>> Hello,
>>>>>>>>        I am new to this Library. Its working great, i used logo
>>>>>>>> (image) in the excel sheet. with the auto sizing the image also
>>>>>>>> expanding and contracting according to that column data. 
>>>>>>>> 
>>>>>>>> Can i keep the image irrespective of the column size? 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/autosize-in-Excel-irrespetive-of-image-tp24604961p24719823.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