0
votes

I am able to generate one sheet only with the ember-cli-data-export through the following javascript function of:

this.get('excel').export(data, {sheetName: 'Overview', fileName: 'test.xlsx'});

I have tried the following way (below) to generate multiple sheets but it is not working.

this.get('excel').export([data1, data2], {sheetName: ['Overview', ,Next'], fileName: 'test.xlsx'});

How do I generate multiple sheets in one excel file test.xlsx using ember-cli-export?

1

1 Answers

0
votes

ember-cli-data-export isn't able to export multiple worksheets in a single file.

If you take a look at the .export function in the repository you'll see (comments my own)

 var wb = new Workbook(), ws = sheet_from_array_of_arrays(data); //Create a single workbook
 wb.SheetNames.push(options.sheetName); //take the sheetname out of the options and create a new sheet
 wb.Sheets[options.sheetName] = ws; // Push mapped data to the new sheet
 var wbout = XLSX.write(wb, {bookType:'xlsx', bookSST:true, type: 'binary'}); //Store the workbook

 saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), options.fileName); //Prompt for save

If you need multi-sheet saving, you'll need to fork the repo and make modifications to handle multiple sheets or use the xlsx package to write it yourself.