1.多sheet存储
方式一:读取数据库并存入excel多个sheet
import cx_Oracle
import pandas as pd
conn_oracle = cx_Oracle.connect('user','passwd','ip:port/db')
cur_oracle = conn_oracle.cursor()
result = pd.read("sql")
result1 = pd.read("sql1")
writer = pd.ExcelWriter(r'C:\\Users\\admin\\Desktop\\XXX.xlsx')
result.to_excel(writer,sheet_name='XXX')
###不保存索引result.to_excel(writer,sheet_name='XXX',index=False)
###指定索引result.to_excel(writer,sheet_name='XXX',index=["a","b","c"],columns=["one","two","three"])
result1.to_excel(writer,sheet_name='XXX')
writer.save()
writer.close()
方式二:读取excel并进行计算存入excel多个sheet
###写入结果的表
writer = pd.ExcelWriter(r'C:\Users\admin\Desktop\XXX.xlsx')
###读取