0

My code

    var fsobj = new ActiveXObject("Scripting.FileSystemObject");
    var excelApp = new ActiveXObject("Excel.Application");
    excelApp.DisplayAlerts = false;

    var wbobj = excelApp.Workbooks.Add;
    var wsobj = wbobj.Worksheets(1);

When I use the below code it works fine (i.e., it executes excel and fills in two rows)

    wsobj.Cells(1,1).value="Hello";
    wsobj.Cells(2,1).value=compareData.response.length;
    wbobj.Application.visible=true;

But when I use this below code it says Expected ';' in 3rd line (with Hello), I am not able to find what is the problem here. Here is the jsfiddle link, not working though, if anyone can make it work

    for(i=0;i<compareData.response.length;i++)
    {
        wsobj.Cells(i,1).value="Hello";
    }
    wbobj.Application.visible=true;

1 Answer 1

1

Row numbers in Excel start from 1, not from 0. You should write

for(i=0; i<compareData.response.length; i++)
{
    wsobj.Cells(i + 1, 1).value="Hello";
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.