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



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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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