我使用xlwt
与Python从某些东西获取一些数据,并将其写入xls
文件,但我需要在不同范围的单元格中获取输出。 我有这样的代码: -我如何获得不同范围的细胞值?
#Here's the code for that :
import xlwt
from tempfile import TemporaryFile
book = xlwt.Workbook()
sheet1 = book.add_sheet('sheet1')
a=[1,2,3,4,5]
b=[6,7,8,9,10]
c=[2,3,4,5,6]
data = [a,b,c]
for row, array in enumerate(data):
for col, value in enumerate(array):
sheet1.write(row, col, value)
name = "table.xls"
book.save(name)
book.save(TemporaryFile())
输出( “table.xls”):
#Output
* A B C D E
1 1 2 3 4 5
2 6 7 8 9 10
3 2 3 4 5 6
但我想是这样的:
# I want the values in different ranges of cells
* A B C D E F G H I
1 1 6 2 3 4 5 6
2 2 7
3 3 8
4 4 9
5 5 10
谁能帮助我?感谢
我看到你想要第一个和第二个列表作为列和第三个列表作为行...是否正确? –
@铁拳是的。 –
@ Iron Fist ...我也需要你的帮助http://stackoverflow.com/questions/34676285/how-can-i-create-duplicate-sheets-from-sheet1-then-input-list-data-in -those-s –