Hello, I have created one button for exporting data into an excel file but it is storing an excel file locally on the system .instead of that I want to download that file with a button click. here is my code.
def object_button(self):
lists = []
for rec in self:
# project_detail_ids field of estimation table
for record in rec.project_detail_ids:
dicts = {}
for task in record.task_id:
print('task category_id', task.category_id)
print('dicts inside ---------------', dicts)
print("task_name=====>",task.module_name)
dicts['Catgory_name'] = task.category_id.category_name
dicts['Module_Name'] = task.module_name
dicts['Hours'] = record.hours
dicts['Notes'] = record.task_notes
dicts['Total_Hours']= self.total_hours
print('inside',dicts)
lists.append(dicts)
df = pd.DataFrame.from_dict(lists)
print("data frame==>",df)
# add data in excel sheet
data = df.to_excel('estimation.xlsx',index=False)
print(lists)
# st.download_button(label='Download',
# data=data,
# file_name= 'estimation.xlsx')
return {
'effect': {
'fadeout': 'slow',
'message': 'Export Successfully.. !!',
'type': 'rainbow_man',
}
}