I'm using Sparx Enterprise Architect to create a script that needs to generate an Excel file. Until now I've used VBScript and JScript, but I need for a new project to implement it with Javascript. Sparx EA uses Mozilla SpiderMonkey JS v1.8.
I started with the following code:
function main()
{
try {
var objExcel= new COMObject("Excel.Application",true);
var objWorkbook = objExcel.Workbooks.Add(true);
var objWorksheet = objWorkbook.Sheets.Add("",1);
}
catch (ex)
{
Session.Output("exception " + ex);
}
}
main();
Unfortunately this generates the following error: exception TypeError: objWorkbook is undefined
From MS documentation Workbook:
public object Add (object Before, object After, object Count, object Type);All parameters are optional, if no parameter is passed it returns a Worksheet
You can see online documentation here