[bug-15748]system.dataset.toExcel doesn't allow multiple sheets

Just updated my project to 8.0.7 to use the new toExcel function for some data export functions, and instead of putting a dataset on each sheet, it puts one sheet with one column called value as shown below. Was there anything else changed on this function that I may have missed? Or is this a bug due to the changes?

I was really hoping to avoid the mismatched file extension errors in excel by using the new function, but the old function works in the meanwhile still I guess.

How are you calling the script? It looks like maybe you’ve got an extra layer of lists of datasets being passed, or the function is coercing what you’re passing in to a single value somehow.

Below is the bit of chaos that is the prep for that export. If I swap toExcel, for dataSetToExcel, it works and has data on separate sheets, but it throws the mismatched file type errors if I use that function.

data2 =  system.db.runNamedQuery('Reports/KPI/St2',{'StartDate':startDate,'EndDate':endDate})
data5 =  system.db.runNamedQuery('Reports/KPI/St5',{'StartDate':startDate,'EndDate':endDate})
data5B = system.db.runNamedQuery('Reports/KPI/St5B',{'StartDate':startDate,'EndDate':endDate})
data4 =  system.db.runNamedQuery('Reports/KPI/St4',{'StartDate':startDate,'EndDate':endDate})
data6A = system.db.runNamedQuery('Reports/KPI/St6A',{'StartDate':startDate,'EndDate':endDate})
data6B = system.db.runNamedQuery('Reports/KPI/St6B','StartDate':startDate,'EndDate':endDate})
data7 =  system.db.runNamedQuery('Reports/KPI/St7',{'StartDate':startDate,'EndDate':endDate})
data8 =  system.db.runNamedQuery('Reports/KPI/St8',{'StartDate':startDate,'EndDate':endDate})
dataE =  system.db.runNamedQuery('Reports/KPI/EOLT',{'StartDate':startDate,'EndDate':endDate})
data = [data2,data5,data5B,data4,data6A, data6B,data7,data8,dataE]
excel = system.dataset.toExcel(1, data,1)
path = system.file.saveFile("reportData.xls","xls", "Excel Workbook")
if path is not None:
   system.file.writeFile(path, excel)

Whoops, I see the problem. Easy fix. I’ll get a bug ticket going.

1 Like

This issue is fixed in 8.0.10.