我有一个脚本,它从xlrd中的一个excel读取数据,然后将该数据写入另一个使用xlsx writer省略第一列的excel文件。问题是我需要将新文件保存为xls。有什么办法吗?另外,无论如何要在worksheet.add_table()中使用header和data参数?谢谢!
workbook = xlrd.open_workbook(outXL)
writeBook = r"S:Upload\SVRSTA00.xls"
sheet = workbook.sheet_by_index(0)
cell_range_value = 0
for value in sheet.col(32):
cell_range_value += 1
print cell_range_value
data = []
for i in range(0, cell_range_value,1):
stuff = [sheet.cell_value(i, col) for col in range(sheet.ncols)[1:]]
print stuff
data.append(stuff)
#Create a workbook and add worksheet.
workbook = xlsxwriter.Workbook(writeBook)
worksheet = workbook.add_worksheet("SVRSTA00")
worksheet.add_table(0,0,32, cell_range_value,{'data': data})
workbook.close()