Forum Discussion

shane_manjunath's avatar
shane_manjunath
Occasional Contributor
8 years ago
Solved

How to write into excel file using Javascript?

I have written the following javascript to write into excel.However "book.Sheets" doesn't seem to exist so I am unable to create sheet object   Also when It tries to execute the code - app.Cells(1,...
  • HKosova's avatar
    8 years ago

    In JavaScript (not JScript) you need to access Excel collection items by using the .Items property:

     

    book.Sheets(sheetName) => book.Sheets.Item(sheetName)
    app.Cells(1,1) => app.Cells.Item(1,1)

    etc.

     

    More details here: https://support.smartbear.com/viewarticle/82954/#collections

     

    Also, you can't assign to a cell directly because it's an object, you need to use something like:

    app.Cells.Item(1,1).Value2 = "test";