Archi Forum

Archi Plug-ins => jArchi => Topic started by: René on March 01, 2021, 14:44:27 PM

Title: Making multiple Excel-Sheets
Post by: René on March 01, 2021, 14:44:27 PM
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?
Title: Re: Making multiple Excel-Sheets
Post by: Phil Beauvoir on March 01, 2021, 14:55:46 PM
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.
Title: Re: Making multiple Excel-Sheets
Post by: René on March 01, 2021, 16:59:01 PM
Thanks.

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