import pandas as pd
sheet_names = ["DuplicatesInBase", "DuplicatesInRun", "OnlyInBase", "OnlyInRun", "Differences_Base_Run", "Matched_Base_Run"]
with pd.ExcelWriter('/apps/Reports/Trade_Id_$[ReconcileDate].xlsx', engine='xlsxwriter') as writer:
for sheet in sheet_names:
#print(sheet)
sql_statement = 'select * from ' + sheet
#print(sql_statement)
s_df = spark.sql(sql_statement)
df1 = s_df.toPandas()
df1.to_excel(writer, sheet_name=sheet)