1
2
3
4
5
6
7
8
9
|
import pandas as pd
f = pd.ExcelFile('./data/meal_order_detail.xlsx')
f.sheet_names # 获取工作表名称
data = pd.DataFrame()
for i in f.sheet_names:
d = pd.read_excel('./data/meal_order_detail.xlsx', sheetname=i)
data = pd.concat([data, d])
data.shape
|
1
2
3
4
5
6
7
8
9
10
11
|
write = pd.ExcelWriter(excel_filepath)
df1 = pd.DataFrame(d_f1)
excel_header = ['日期','年龄']#excel的标题
df1.to_excel(write,sheet_name='Sheet1',header=excel_header,index=False)
df2 = pd.DataFrame(d_f2)
excel_header = ['日期','人数']
df2.to_excel(write,sheet_name='Sheet2',header=excel_header,index=False)
write.save()
|
如果有更高的需求,比如指定字体,则需要使用xlrd
(读)和xlwt
(写)
1
2
3
4
5
|
import xlwt
style = xlwt.XFStyle()
font = xlwt.Font()
font.name = 'SimSun' # 宋体
style.font = font
|
Reference
1、 https://blog.csdn.net/Animeisme/article/details/91960382
2、 https://blog.csdn.net/wangxingfan316/article/details/79628463
打赏
微信
|
支付宝
|
万分感谢 |
|