I have a list l1=[[12,23,45],[23,44,47],[34,67,88]]
. I want to save l1
as an Excel file using xlsxwriter
with the following format:
number1 number2 number3
12 23 45
23 44 47
34 67 88
If you dont want to use pandas then you can just use write function of xlsxwriter:
import xlsxwriter
l1=[[12,23,45],[23,44,47],[34,67,88]]
workbook = xlsxwriter.Workbook('temp.xlsx')
worksheet = workbook.add_worksheet()
row = 0
for i in range(len(l1[0])):
worksheet.write(row, i, "number"+str(i+1))
row += 1
for items in (l1):
for i in range(len(items)):
worksheet.write(row, i, items[i])
row += 1
workbook.close()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.