Image inserting

158 views
Skip to first unread message

Grigoriy Petukhov

unread,
Nov 27, 2008, 11:54:56 PM11/27/08
to python-excel
Hi, all.
I want to insert image. Could anybody explain me how to setup the size
of inserted image?
As I see the size of image depends on the width of cell and on the
font height of cell and I'm very confused and need help. All that I
want is just to insert image to top left corner of document and keep
oroginal size of image.
Thanks )

Grigoriy Petukhov

unread,
Nov 28, 2008, 2:29:11 AM11/28/08
to python-excel
I need to insert image to (0, 0) cell and also setup the width of 0
column. If I don't touch the width than inserted image looks fine, but
if I change the width of column befor or after inserting the image
then the size of image changes :-(

John Machin

unread,
Nov 28, 2008, 3:29:52 AM11/28/08
to python...@googlegroups.com


Hi, Grigoriy,

I'm afraid I can't help you with images as implemented in Bitmap.py. The
method used is an antique, pre-dating BIFF8. If you write a file
containing such an image with xlwt, open it with Excel and save it
again, the image is converted to the BIFF8 format. There is no support
in xlwt for the new format, which is more complicated than the old one
by a few orders of magnitude. There was minimal documentation in the OOo
docs last time I looked. The docs that MS released within the last year
or so have critical chunks of data described as "reserved" (not in the
sense of "zero-fill this stuff, we might use it later" but "we use it
now, we're just not going to tell you what it is"). The chance of this
getting on my TODO list is zero ... unless someone sends impressive
quantities of coders, guns, and money :-)

Maybe there is someone out there who has fiddled with row heights, font
sizes, column widths, etc and can suggest some way around your problem.
Anyone?

Cheers,
John

John Machin

unread,
Dec 1, 2008, 12:16:52 AM12/1/08
to python...@googlegroups.com
On 28/11/2008 19:29, John Machin wrote:
> On 28/11/2008 18:29, Grigoriy Petukhov wrote:
>> I need to insert image to (0, 0) cell and also setup the width of 0
>> column. If I don't touch the width than inserted image looks fine, but
>> if I change the width of column befor or after inserting the image
>> then the size of image changes :-(

> I'm afraid I can't help you with images as implemented in Bitmap.py.

A little premature :-)

> Maybe there is someone out there who has fiddled with row heights, font
> sizes, column widths, etc and can suggest some way around your problem.
> Anyone?

After some messing about, I discovered that Worksheet.col_width(col) [in
pixels] was returning a constant answer (64 pixels) :-(

After fixing this, the effect is that if you set the column width [in
256ths of the standard character width] *before* you insert the picture,
the picture will be OK. Changing the column width afterwards will
stretch or squash the picture.

This fix is now in the svn trunk. I have included
.../examples/image_chg_col_wid.py which demonstrates the effect of
increasing/decreasing the column width before/after inserting the image.

Please try it with your app and let us know the result.

TODO: Check that changing the row height works.

Cheers,
John


Grigoriy Petukhov

unread,
Dec 1, 2008, 12:56:14 AM12/1/08
to python-excel
Thanks. It works now! :-)
Reply all
Reply to author
Forward
0 new messages