title: exporting excel sheet from gridview in asp.net
body: <p>I'm exporting excel sheet from my gridview which i bind with dummy data. I'm using jquery mehod of exporting excel but its not working. i have the following function in jquery.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function exportToExcel() 
      {
          var oExcel = new ActiveXObject("Excel.Application");
          var oBook = oExcel.Workbooks.Add;
          var oSheet = oBook.Worksheets(1);
          var detailsTable = document.getElementById('&lt;%= gvSearchResult.ClientID %&gt;');
          alert(detailsTable);
          for (var y=0;y&lt;detailsTable.rows.length;y++) 
          // detailsTable is the table where the content to be exported is 
          { 
              for (var x=0;x&lt;detailsTable.rows(y).cells.length;x++) 
              { 
                  var cellData = detailsTable.rows(y).cells(x).innerText;
                  var cellHTML = detailsTable.rows(y).cells(x).innerHTML;
  
                  if (cellHTML.toLowerCase().indexOf("&lt;table") == -1 &amp;&amp; cellHTML.toLowerCase().indexOf("schedule") == -1) // check to omit page numbers
                  {
                      oSheet.Cells(y+1,x+1) = cellData;
                  }
              } 
          } 
          oExcel.Visible = true; 
          oExcel.UserControl = true; 
      }
  </code></pre>
  
  <p></p>
  
  <p>i use the above function. i'm have a button on click i want to export the excel sheet. the button is as: </p>
  
  <pre><code>&lt;asp:Button runat="server" ID="btnClickXport" Text="Xport2Xcel" OnClientClick="exportToExcel()" /&gt;
  </code></pre>
  
  <p>its not working. i test actually new ActiveXobject("Excel.Application"); in the start cause problem. what i need to do?</p>