Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Bug in row.height ?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
John Yeung  
View profile  
 More options Dec 30 2009, 11:47 pm
From: John Yeung <gallium.arsen...@gmail.com>
Date: Wed, 30 Dec 2009 23:47:58 -0500
Local: Wed, Dec 30 2009 11:47 pm
Subject: Re: [pyxl] Bug in row.height ?

On Wed, Dec 30, 2009 at 10:10 PM, John Machin <sjmac...@lexicon.net> wrote:
>> As a vague idea (weaker than a suggestion), it might be easier, or at
>> least less cryptic, to add a Row.set_height method and point people to
>> it in the tutorial, than to explain in the tutorial that they have to
>> set both height and height_mismatch.

> Your vague idea covers behaviour A, leaving the tutorial to explain that
> if behaviour B is required, they must not set height_mismatch to True
> etc etc.

Yeah, pretty much.  (I suppose an admonition not to expect behavior B
if you use the set_height method is part of the etc.)

> Your proposed method would do nothing else but set the height
> attribute to the arg value and setting height_mismatch to 1. Do
> you plan on not documenting why height_mismatch is set to 1?
> Perhaps you'd like to explain what you mean by "easier" and
> "less cryptic".

I was thinking (and keep in mind I've not proven myself smarter than a
bricked and kicked horse) that it would take less verbiage (easier)
and be more readily understandable (less cryptic) to the uninitiated
reader for the tutorial to say "set the row height to a fixed number
of twips using Row.set_height" than to even mention height_mismatch at
all.  I'll admit I haven't given much thought to cases where it would
be nice to have easy access to height_mismatch other than to set a
fixed row height.  I doubt I would miss it if this property were not
exposed in the API at all, but then I'm sure that would break someone
else's code.

I would document the height setter method, including why it's setting
height_mismatch, in the source code (presumably in Row.py); that would
be plenty clear enough for spelunkers but out of the way for less
curious get-the-job-done types.

It probably also goes without saying that it's both easier and less
cryptic for the xlwt user to write

  ws.row(r).set_height(h)

than

  ws.row(r).height = h
  ws.row(r).height_mismatch = True  # needed to force height setting

or to bundle away the latter in his own function or module.  Or to
futz with his xlwt installation so that he doesn't need to
(thereafter) include his own function or module.

>> Oh, it might be useful to mention that the reason I was investigating
>> setting the row height in the first place was because I couldn't coax
>> Excel into doing automatic height adjustment to accommodate wrapped
>> text in merged cells.

> I presume you didn't read far enough into that cryptic message
> to get to the mention of the demo script :-(

I actually didn't find your message cryptic at all, once I was in the
proper frame of mind to pay attention to it.  I wasn't in the proper
frame of mind initially because I was thinking to myself that I wasn't
having the problem that the OP was having, so it wouldn't do me much
good to read on.  (I guess at the time I was being a less-curious,
get-the-job-done type.)

Once I did read on, I did see the mention of the demo script, and I
even read it, but it is not easy for me to try it out on this
computer.  I will give it a go tomorrow.

Also, I'm sure you're referring to the write_merge toward the end of
the script, but I have come to not use write_merge, because I haven't
had success with it and borders.  Instead, I've got my own
Frankenmerge that better serves my needs (but for all I know is crap
for anyone else):

def merge(sheet, r1, c1, r2, c2, label, style):
    sheet.merge(r1, r2, c1, c2)
    for row in range(r1, r2 + 1):
        for col in range(c1, c2 + 1):
            if row in (r1, r2) or col in (c1, c2):
                if (row, col) == (r1, c1):
                    value = label
                else:
                    value = None
                sheet.write(row, col, value, style)

>>  (As far as I can tell, this is a bug in Excel
>> 2000 and doesn't imply any deficiency in xlwt.)

> Can you produce the required behaviour using the Excel UI?

I can't get the Excel UI to automatically accommodate wrapped text in
merged cells, which is why I figured it was an Excel bug, and not a
problem with xlwt.  However, it is also entirely possible that my
Excel-fu is simply insufficient.

John Y.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.