0

I have a SharePoint 2013 list. Using jquery I have exported the data into a table and added customized code for export to excel to that particular table data. But am getting an error

Automation server can't create object** at the line * excel = new ActiveXObject('Excel.Application');

while I try to export. PFB code to export:

function CreateExcelSheet() {
  var i, j, str,str1,k,l,m,n,

   myTable1 = document.getElementById('project'),
            rowCount1 = myTable1.rows.length,
            excel = new ActiveXObject('Excel.Application');// Activates Excel
    excel.Workbooks.Add(); // Opens a new Workbook
    excel.Application.Visible = true; // Shows Excel on the screen
    for (i = 0; i < rowCount1; i++) {
      for (j = 0; j < myTable1.rows[i].cells.length; j++) 
        //for (j = 0; j < 11; j++) 
        {
            str1 = myTable1.rows[i].cells[j].innerText;
            excel.ActiveSheet.Cells(i + 1, j + 1).Value = str1; // Writes to the sheet
            k=i;
            l=j;
        }



    }


    return;
}
4
  • Do someone have any idea on this?
    – Dheeraj
    Commented Apr 7, 2017 at 9:50
  • Hello...Can somebody answer?
    – Dheeraj
    Commented Apr 11, 2017 at 14:16
  • Going off this answer: stackoverflow.com/questions/5157183/… it looks like the error 'Automation server can't create object' has to do with your browser settings. Is your website added to Trusted Sites in Internet Explorer, and have you checked the ActiveX settings for Trusted Sites?
    – Ted N.
    Commented Apr 11, 2017 at 21:11
  • Check this: social.msdn.microsoft.com/Forums/en-US/… Commented Apr 11, 2017 at 21:34

1 Answer 1

0

Why don't you get list data in Jquery data-tables instead? it has very good look and feel and you get inbuilt buttons to export, print etc.

Just get the list data in json format using REST query and put it in datatable and use export excel, pdf etc buttons

1
  • I tried that but somehow export to excel is not working...it is exporting but it is not displaying any data
    – Dheeraj
    Commented Apr 13, 2017 at 8:46

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.