On Tue, Apr 27, 2010 at 12:52 PM, John Machin <
sjma...@lexicon.net> wrote:
> On 28/04/2010 1:19 AM,
barb...@voila.fr wrote:
>> I used this workaround (can't remember where I found it):
>
> The following code does (laboriously!) what the standard write_merge method
> does.
>
>> # then writing in first cell
>> sheet.write(r1, c1, label, style)
>> for row in range(r1, r2 + 1):
>> for col in range(c1, c2 + 1):
>> if not (row == r1 and col == c1):
>> #writing empty values in other cells
>> sheet.write(row, col, None, style)
>> sheet._cell_overwrite_ok = overwriteOk
It may laboriously do what the standard write_merge is *supposed* to
do, but I have also had occasion to use a similar workaround (only
writing cells along the outer edge), which worked better for me than
the standard write_merge. Granted, my needs include being able to run
on an iSeries, and I use a tweaked version of xlwt 0.7.1.
But, for gits and shiggles, I just threw a clean[1] xlwt 0.7.2 onto my
Windows XP machine running Python 2.5.1, and promptly got a nice
merged.xls and merged0.xls, but a problematic merged1.xls (all opened
with Excel 2000). The upper left cell in each merged range fails to
have a border.
I notice that merged.py and merged0.py use the write_merge method and
seemed to work fine; while merged1.py uses the merge method and had a
problem. I also notice that comments in the source code for the merge
method say to avoid its use, and to use write_merge instead.
Evidently, that is sound advice on my PC.
But the standard write_merge didn't work with my iSeries tweaks (it's
been so long since I worked on it that I don't remember what the
symptoms were; possibly that all *but* the upper left cell were
missing the border?). Maybe my tweaks are not compatible with
MulBlankCell (which seems to be the less laborious way to write
blanks?).
In any case, using the standard, broken merge method and then
splatting individual cells over the top of the resulting area has
reliably worked for me both on the PC and iSeries, so I no longer use
the standard write_merge at all.
> It would help if you could reproduce the problem using the merged.py in the
> examples folder, and put up a copy (renamed to indicate the source e.g.
> 'merged_barbuse_sunos_244_072.xls') of the output merged.xls in this group's
> file area, and say what the observed problem was with each of the three
> sheets in the file.
If you would like me to do this for my examples as well, I can when I get home.
John Y.
[1] It's clean to the extent that I just plopped the naked xlwt Python
source into site-packages. Maybe this is not the intended way to
"install" it, but the fact that the extract-and-copy method works for
xlwt is one reason I am quite happy with the package.