pictures in single cells - conflict with wrapping text
On Dec 14, 5:59*pm, "Peter T" <peter_t@discussions wrote:
I hadn't digested in your first post that in effect the xls is being created
with BIFF8. The makers of Apache POI have done well because until recently,
when MS published the BIFF8 in full under the open source agreement, the
documentation about drawing objects was very thin.
I've seen reference to BIFF8 on POI discussion threads, but don't know
what it is. From the context of those posts, I was under the
impression that BIFF was a tool to display your XLS in an XML format.
Are you saying that BIFF8 is one of several file formats that Excel
refers to as .XLS? In any case, yep, that seems to be what POI
implements.
I don't know at what point the object first creates a reference to its
TopLeft and BottomRight cells, particularly when created with BIFF8, maybe
only after the file is first used in Excel and perhaps that's what's giving
you a problem. Not sure if for your purposes it might be worth finding out
if those cells can be returned in BIFF8, as they can via Excel's object
model.
Yep. It seems to be that 'first used in Excel' condition that's the
problem. I did an experiment, though, and rigged up a report that had
pictures in the first column only and wrapping text in the next
column. The pictures were still stretched to the height of the rows
after the text was wrapped, so I don't seem to be able to control that
'first use in Excel' condition. Or, in any case, it's not as simple
as 'the first cell Excel encounters on a row'.
I suppose the obvious question is why not automate Excel, even if only to
tidy things up in the file that was originally created elsewhere.
Well, the file's created on an AIX system, so can't automate Excel
there. And it's produced for download to a browser, so can't really
automate Excel there either. I guess the end-user could do it, but
again, I'm not even sure how I'd automate this. You'd need logic to
figure out which cells are affected (my xls-creating facility is
general purpose - produces any number of different xls layouts), and
then automate resizing the pictures. Best would be a way to insert
the pictures at a fixed size in points or pixels or whatever. But as
you point out, the BIFF8 thingy doesn't seem to allow that.
As it stands, the best compromise I can think of is to just set the
row height to inhibit automatic wrapping whenever I insert a picture
into a cell. The user can then expand the rows to see the wrapping
text. That's easy enough to do by highlighting the entire first
column of the spreadsheet and then hitting Format-Row-Auto Fit.
Excel's nice enough to leave the pictures alone after it's rendered
them the first time, so that'd work out okay.
Thanks for addressing my question. The info about BIFF8 is useful in
understanding things in POI that don't seem to make sense.
Rob
|