|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
×
求助各位大佬 不知道为啥报错了 谢谢!
代码如下
from xlutils.copy import copy
import xlrd
import xlwt
xlsx = xlrd.open_workbook('d:/算.xlsx',formatting_info=True)
table = xlsx.sheet_by_index(0)
new_excel = copy(xlsx)
new_sheet = new_sheet.get_sheet(0)
style = xlwt.XFStyle()
font = xlwt.Font()
font.name = '微软雅黑'
font.bold = True #加粗
font.height = 360 #字size*20
style.font =font
#边框
borders = xlwt.Borders()
borders.top = xlwt.Borders.THIN #细线框
borders.bottom = xlwt.Borders.THIN
borders.left = xlwt.Borders.THIN
borders.right = xlwt.Borders.THIN
style.borders =borders
#对齐
alignment = xlwt.Alignment()
alignment.horz = xlwt.Alignment.HORZ_CENTER
alignment.vert = xlwt.Alignment.VERT_CENTER
style.alignment = alignment
new_sheet.write(2,1,12,style)
new_sheet.write(3,1,15,style)
new_sheet.write(4,1,18,style)
new_excel.save('d:/test.xls')
报错如下
Traceback (most recent call last):
File "c:\Users\11573\python练手\复制格式.py", line 1, in <module>
from xlutils.copy import copy
ModuleNotFoundError: No module named 'xlutils'
但是我已经装了这个模块
PS C:\Users\11573\python练手> pip install xlutils
Requirement already satisfied: xlutils in c:\python38\lib\site-packages (2.0.0)
Requirement already satisfied: xlwt>=0.7.4 in c:\python38\lib\site-packages (from xlutils) (1.3.0)
Requirement already satisfied: xlrd>=0.7.2 in c:\python38\lib\site-packages (from xlutils) (1.2.0) |
|