如何从sheet1创build复制表单,然后在这些表单中input列表(数据)?
我使用xlwt
和xlrd
与Python从某些东西获取一些数据,并将其写入一个xls
文件,但我需要在不同的工作表中获得输出。 我想创build(N)个sheet1的重复副本,然后在这些工作表(sheet2,sheet3,… sheetN)中input(data)的列表,
我有这样的代码: –
from xlrd import open_workbook from xlwt import easyxf from xlutils.copy import copy data = [['2008','2009','2011'],['Jan','Feb','Feb'],[100,200,300]] ##Here ...I want creat (N) number of duplicate copies of sheet1 rb = open_workbook('this1.xls') rs = rb.sheet_by_index(0) wb = copy(rb) ws = wb.get_sheet(0) ##Here I want to do loop to input (data) in sheets (sheet2,sheet3,...sheetN) . for i,row in enumerate(data): for j,cell in enumerate(row): ws.write(j,i,cell) wb.save('outlines.xls')
输出( “outlines.xls”):
输出(表1)
* ABC 1 2008 Jan 100 2 2009 Feb 200 3 2011 Feb 300
但是我想要这样的输出:
sheet (2): * A 1 2008 2 2009 3 2011 sheet (3): * A 1 Jan 2 Feb 3 Feb sheet (N): - - -