Making multiple Excel-Sheets

Started by René, March 01, 2021, 14:44:27 PM

Previous topic - Next topic

René

March 01, 2021, 14:44:27 PM Last Edit: March 01, 2021, 14:48:29 PM by René
I wanna write an export with more than one sheet:

// Create a new Excel file with a default font and colour
var excel = $JExcel.new("Calibri 12 #333333");

// Add a new sheet with a name
excel.set( { sheet:0, value:type0 });

// Add a new sheet with a name
excel.set( { sheet:1, value:"res" });


The last line I got the following message:
Script Error: javax.script.ScriptException: Bad sheet 1 in file: [..]lib/myexcel.js at line number 210 at column number 28

What's wrong?

Phil Beauvoir

I looked at the source code for myexcel.js and found that you have to add the sheet like this:

excel.addSheet("res");

It seems a new Excel object adds one sheet by default (0) so the call to set is only setting its name.
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

René

Thanks.

That means: the first one is still existing by creating JExcel.new, so I just have to give them a name.