View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Y. Rob Y. is offline
external usenet poster
 
Posts: 4
Default pictures in single cells - conflict with wrapping text

I'm using Apache POI to generate XLS's, and have mastered the 'art' of
sizing pictures with anchors. But I've run up against a brick wall
(or, at least, a catch-22).

I have some columns that want to auto-wrap text. Excel is nice enough
to do this for me, but in the process it changes the row height. The
problem is that if I also have a picture anchored to a cell on that
row, Excel interprets the anchor based on the new row height *after*
it's wrapped the text. This results in the picture being stretched to
the height of the multi-line row. Since I'm counting on Excel to size
the rows, it's kind of silly for Excel to treat the anchor as though I
knew the row size upfront.

This only happens the first time Excel opens the spreadsheet. If I
modify the row after opening the spreadsheet, Excel respects the 'move
with cell but don't resize' option. And of course, if I create a
spreadsheet manually in Excel rather than programmatically, there's no
problem. Excel seems to set the initial anchor to match the picture
size and adjust it as needed when wrapping text causes the row to grow
(is that right, or does Excel convert the anchor to some other
positioning/sizing object internally?).

I can sort of get around this by setting the row height explicitly.
That prevents my pictures from being stretched because it also
prevents Excel from auto-wrapping my text. Bottom line is that I can
either have fixed-size pictures or auto-wrapping text, but not both.
Is this true?

Thanks,
Rob