There are two javascript function .
the second method would call the first function passing two parameter.
in load_wood_excel function i am not able to access the parameter..
can any ony tel me how to pass interger , and also how to access the parameter in function????????

function load_wood_excel(row,column){
            alert(row);
            alert(column);

            var Excel;
            Excel = new ActiveXObject("Excel.Application");
            Excel.Visible = false;
            alert("pooran");
            return              Excel.Workbooks.Open("C:/Users/chandrpo/Desktop/othla/OPJ/ram.xls").ActiveSheet.Cells('row','column').Value;
            }

        function iterateExcel(){
        var row = 2;
        var column = 1;
        var someArray = new Array();
        do 
                {
                item = load_wood_excel();
                if(item !=null){
                var i = 0;
                someArray[0]= item;
                i++;
                row++;
                }
                item1 = load_wood_excel(2,1);
                }while (item != null || item1 != null);
        }

Dani AI

Generated

Quick summary and next steps (building on 's pointers): the function needs to be called with the numeric variables you declared, and Excel's Cells expects numeric (1‑based) indices — not quoted strings. Also avoid reopening Excel on every call and make sure you close/quit the COM objects so EXCEL.EXE doesn't keep running.

Example: a small helper that reads one cell (shows how integers are passed and used):

function readCellFromExcel(rowIdx, colIdx, filePath) {
  var excel = new ActiveXObject("Excel.Application");
  excel.Visible = false;
  var wb = excel.Workbooks.Open(filePath);
  var ws = wb.ActiveSheet;
  var val = ws.Cells(rowIdx, colIdx).Value;
  wb.Close(false);
  excel.Quit();
  return val;
}

Better approach for iterating rows: open the workbook once, loop until you hit an empty cell, then close. This avoids repeated Open/Quit overhead and resource leaks.

function processRows(filePath) {
  var excel = new ActiveXObject("Excel.Application");
  excel.Visible = false;
  var wb = excel.Workbooks.Open(filePath);
  var ws = wb.ActiveSheet;
  for (var r = 2;; r++) {
    var v = ws.Cells(r, 1).Value;
    if (v === null || v === undefined) break;
    // handle v (push into array, etc.)
  }
  wb.Close(false);
  excel.Quit();
}

Practical notes and troubleshooting:

  • Cells uses 1‑based integers: pass numbers, not quoted strings. If you receive strings, coerce with Number() or parseInt().
  • JavaScript passes primitives by value; calling readCellFromExcel(r, c) sends the numeric values fine.
  • Always clean up COM objects (Close + Quit) and wrap operations in try/catch/finally to guarantee cleanup on errors.
  • ActiveX is IE/intranet only and requires permissions; for public-facing apps use a server‑side solution instead.
  • If results are still odd, add typeof/console logging for the parameters and the cell value to confirm types and presence.

For : replace the no-argument calls with calls that pass your row/column variables and use the pattern above to avoid the undefined/quoted-index issues.

In iterateExcel() , you establish var row = 2; and var column = 1; but don't use either of them.

In the do/while loop, load_wood_excel() is called first without, then with arguments. Try calling the function once with load_wood_excel(row,column) instead of load_wood_excel(2,1) . Adjust the while clause accordingly.

In load_wood_excel(), ...ActiveSheet.Cells('row','column')... , are 'row' and 'column' supposed to be strings? ...ActiveSheet.Cells(row,column)... makes more sense.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.