OK name the file as .xlsx instead of .xls
This is the code that I have that is working
#Export the ticket list to excel.
tickets = self.view.custom.tickets
if len(tickets) > 0:
headers = tickets[0].keys()
dataSet = [list(data.values()) for data in tickets]
ticketsExcel = system.dataset.toExcel(True,system.dataset.toDataSet(headers,dataSet))
fileName = 'Tickets_{}.xlsx'.format(
system.date.format(system.date.now(),'yyyMMd_kms')
)
system.perspective.download(fileName,ticketsExcel,'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
The only other thing I did was to add the contentType of “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”. I’m not thinking that that makes a difference though.