本文说明如何使用 xlsxwriter、pandas、openpyxl 三个库来实现数据写入 Excel,写入后的格式如下图所示:
以下为数据用例:
import xlsxwriter as xw
import pandas as pd
import openpyxl as op
"-------------数据用例-------------"
orderIds = [1,2,3]
items = ['A','B','C']
myData = [10,20,30]
testData = [orderIds,items,myData]
filename1 = '测试1.xlsx'
filename2 = '测试2.xlsx'
filename3 = '测试3.xlsx'
"--------------执行----------------"
xw_toexcel(testData,filename1)
pd_toexcel(testData