I have written a python code to store data in csv format but now need to store in .xlsx file. how to convert the below code and write the output in .xlsx file.
details_file = self.get_local_storage_path() + '/Myfile.xlsx'
csv_columns = (
'id', 'name', 'place', 'salary', 'email',
)
with open(details_file, 'w') as csvfile:
writer = csv.DictWriter(
csvfile, fieldnames=csv_columns, extrasaction='ignore')
writer.writeheader()
for data in details:
writer.writerow(data)
#I tried as below but getting error as TypeError: int() argument must be a string, a bytes-like object or a number, not 'dict'
with open(details_file, 'w') as csvfile:
print("inside open")
workbook = xlsxwriter.Workbook(csvfile)
worksheet = workbook.add_worksheet()
print("before for loop")
for data in details:
worksheet.write(data)
workbook.close()