xlrd是0.7.1的,xlwt是0.7.2的.
可是我在运行xlwt/example/下的例子时,绝大部分都会报告错误:
以例子程序merged.py为例:改源程序如下:
#!/usr/bin/env python
# -*- coding: windows-1251 -*-
# Copyright (C) 2005 Kiseliov Roman
from xlwt import *
fnt = Font()
fnt.name = 'Arial'
fnt.colour_index = 4
fnt.bold = True
borders = Borders()
borders.left = 6
borders.right = 6
borders.top = 6
borders.bottom = 6
al = Alignment()
al.horz = Alignment.HORZ_CENTER
al.vert = Alignment.VERT_CENTER
style = XFStyle()
style.font = fnt
style.borders = borders
style.alignment = al
wb = Workbook()
ws0 = wb.add_sheet('sheet0')
ws1 = wb.add_sheet('sheet1')
ws2 = wb.add_sheet('sheet2')
for i in range(0, 0x200, 2):
ws0.write_merge(i, i+1, 1, 5, 'test %d' % i, style)
ws1.write_merge(i, i, 1, 7, 'test %d' % i, style)
ws2.write_merge(i, i+1, 1, 7 + (i%10), 'test %d' % i, style)
wb.save('merged.xls')
运行时候,报错信息如下:
[abc@linux:/home/xlwt-0.7.2/xlwt/examples]python merged.py
Traceback (most recent call last):
File "merged.py", line 5, in
from xlwt import *
File "/usr/lib/python2.6/site-packages/xlwt/__init__.py", line 12, in
from Row import Row
File "/usr/lib/python2.6/site-packages/xlwt/Row.py", line 10, in
from decimal import Decimal
File "/usr/lib/python2.6/decimal.py", line 138, in
import numbers as _numbers
File "/ttt/tar/xlwt-0.7.2/xlwt/examples/numbers.py", line 8, in
ws = w.add_sheet('Hey, Dude')
File "/usr/lib/python2.6/site-packages/xlwt/Workbook.py", line 324, in add_she
et
self.__worksheets.append(Worksheet.Worksheet(sheetname, self, cell_overwrite
_ok))
File "/usr/lib/python2.6/site-packages/xlwt/Worksheet.py", line 52, in __init_
_
self.Row = Row.Row
AttributeError: 'module' object has no attribute 'Row'
[color=Red]不知道大家是怎么解决的?[/color]
于 2012-02-21 16:52:48发表:
那个错误是说,模块没有row那个属性,你看看代码就知道了嘛!少了哪个模块就导入。
zcf115 于 2010-06-24 20:09:52发表:
我是P的初学者,这个不太清楚,你去ubuntu中文论坛求住吧,找ee帮你解决。