locked
Microsoft JScript runtime error: Automation server can't create object RRS feed

  • Question

  • User1385195316 posted

    i'm trying transfer gridview data to excel.To do this, i'm wrote javascript below.

    When i execute it generates error below.

    Microsoft JScript runtime error: Automation server can't create object 

    How can i solve this problem?

    Thanks.

     

    <script language="javascript" type="text/javascript">

    function CreateExcelSheet() {

    var fso = new ActiveXObject("Scripting.FileSystemObject");

    var xls = new ActiveXObject("Excel.Application");

    xls.visible = true;

    xls.DisplayAlerts = true;

    xlWB = xls.Workbooks.Add();

    xlWB.Sheets.Add(
    null, xlWB.Sheets(xlWB.Sheets.Count));xlWB.WorkSheets(1).Name = "Sorgu Sonuc";

    xlSheet = xlWB.WorkSheets(1);

    xlSheet.Activate();

     

    var gvET = document.getElementById("GV");

    var rCount = gvET.rows.length;

    for (var rowIdx = 0; rowIdx <= rCount - 1; rowIdx++) {

    var rowElement = gvET.rows[rowIdx];

    var clls = rowElement.cells;

    for (var celIdx = 0; celIdx <= clls.length; celIdx++) {

    try {if (clls[celIdx].innerText != null) {

    xlSheet.Cells(rowIdx + 1, celIdx + 1).value = clls[celIdx].innerText;

    }

    }
    catch (err) {

    }

    } //for

    } //for

    }

    </script>

    Monday, March 23, 2009 7:14 PM

Answers

  • User416713816 posted

    You cannot create a FileSystemObject in a browser script.  If this was allowed, it would open all sorts of security issues.

    I noticed you are not even using the fso variable in your script.  What would you be using it for?

    Thanks!

    Eric

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 23, 2009 11:45 PM