Python - 使用 xlsxwriter 将数组值循环到 excel 文件中
Python - Looping in array value into excel file using xlsxwriter
我正在尝试查看是否可以使用 xlsxwriter 模块将数组的值输入到电子表格中。下面给出了我正在使用的数组的视图:
0(5339, '2017-09')
1(670, '2017-10')
2(3268, '2017-11')
3(7645, '2017-12')
4(9999, '2018-01')
5(11987, '2018-02')
6(14354, '2018-03')
7(15782, '2018-04')
8(15465, '2018-05')
9(1473, '2018-06')
10(1661, '2018-07')
11(5679, '2018-08')
12(6927, '2018-09')
谁能帮忙,谢谢..
workbook = xlsxwriter.Workbook('YOUR_FILE.XLSX')
worksheet = workbook.add_worksheet()
# Start from the first cell row 0 and column 0
row = 0
col = 0
# Iterate through the array you have and unpack the tuple at each index
for elm1, elm2 in your_array:
worksheet.write(row, col, elm1)
worksheet.write(row, col + 1, elm2)
row += 1
workbook.close()
我正在尝试查看是否可以使用 xlsxwriter 模块将数组的值输入到电子表格中。下面给出了我正在使用的数组的视图:
0(5339, '2017-09')
1(670, '2017-10')
2(3268, '2017-11')
3(7645, '2017-12')
4(9999, '2018-01')
5(11987, '2018-02')
6(14354, '2018-03')
7(15782, '2018-04')
8(15465, '2018-05')
9(1473, '2018-06')
10(1661, '2018-07')
11(5679, '2018-08')
12(6927, '2018-09')
谁能帮忙,谢谢..
workbook = xlsxwriter.Workbook('YOUR_FILE.XLSX')
worksheet = workbook.add_worksheet()
# Start from the first cell row 0 and column 0
row = 0
col = 0
# Iterate through the array you have and unpack the tuple at each index
for elm1, elm2 in your_array:
worksheet.write(row, col, elm1)
worksheet.write(row, col + 1, elm2)
row += 1
workbook.close()