Hi hhagay,
In JavaScript (not JScript) you need to access Excel collection items via the .Item property. This applies to the .Sheets, .Cells and similar collections.
Also, in JavaScript you cannot assign to an indexed property directly:
sheet.Cells.Item(rowCount, columnCount+1) = rowCount+","+columnCount ;
You need to use either the $set method, or some property of the object you are assigning to:
sheet.Cells.Item.$set(rowCount, columnCount+1, rowCount+","+columnCount);
// or
sheet.Cells.Item(rowCount, columnCount+1).Value2 = rowCount+","+columnCount;
So the working code should look like:
function WriteDataToExcel(fname, sheetName)
{
let app = Sys.OleObject("Excel.Application");
let book = app.Workbooks.Open(fname);
let sheet = book.Sheets.Item(sheetName);
let rowCount = sheet.UsedRange.Rows.Count;
let columnCount = sheet.UsedRange.Columns.Count;
sheet.Cells.Item(rowCount, columnCount+1).Value2 = rowCount+","+columnCount ;
book.Save();
app.Quit();
}
Check out these help topics for other JavaScript specifics:
JavaScript - Specifics of Usage
Differences Between JavaScript and JScript