title: how to export jqgrid into excel from struts2 web page
body: <p>sorry I am new in stack overflow, so I don't know how to post struts2 jsp webpage, but my problem is I am created grid by using j query i want export that grid into excel sheet. how i will do by using struts,j query,jqgrid.</p>
  
  <p><strong>It is my JGrid code</strong></p>
  
  <pre><code>&lt;script&gt;
  
  
      function exportExcel()
      {
          var mya=new Array();
          mya=$("#sample_grid").jqGrid('getDataIDs', {});  // Get All IDs
          var data=$("#sample_grid").getRowData(mya[0]);     // Get First row to get the labels
          var colNames=new Array(); 
          var ii=0;
          for (var i in data){colNames[ii++]=i;}    // capture col names
          var html="";
          for(i=0;i&lt;mya.length;i++)
              {
              data=$("#sample_grid").getRowData(mya[i]); // get each row
              for(j=0;j&lt;colNames.length;j++)
                  {
                  html=html+data[colNames[j]]+"\t"; // output each column as tab delimited
                  }
              html=html+"\n";  // output each row with end of line
  
              }
          html=html+"\n";  // end of line at the end
          alert(html);
          document.forms[0].csvBuffer.value=html;
          document.forms[0].method='POST';
          document.forms[0].action='csvExport.jsp';  // send it to server which will open this contents in excel file
          document.forms[0].target='_blank';
          document.forms[0].submit();
      }
  </code></pre>
  
  <p></p>
  
  <blockquote>
    <p><code>&lt;s:url id="loadGrid" action="loadGrid" namespace="/"/&gt;</code></p>
  </blockquote>
  
  <pre><code>&lt;sjg:grid  href="%{loadGrid}" 
                  gridModel="gridModel" 
                  caption="Grid Sample" 
                  navigator="true" 
                  navigatorAdd="false"
                  navigatorDelete="false"
                  navigatorEdit="false"
                  navigatorRefresh="false"
                  navigatorSearch="false"
                  navigatorView="false"
                  pager="true"
                   navigatorExtraButtons="{
                          add : {
                          caption : 'Export to Excel',
                              title : 'Export to Excel',
                              icon : 'ui-icon-save',
                              onclick: function() {
                                  exportExcel();
                              }
                          }
                      }"&gt;
  &lt;sjg:gridColumn title="Name" name="name" align="left"/&gt;
  &lt;sjg:gridColumn title="City" name="city" /&gt;
  &lt;sjg:gridColumn title="Country" name="country"/&gt;
  &lt;sjg:gridColumn title="Credit Limit" name="creditLimit"/&gt;   
  </code></pre>
  
  <p><code>&lt;/sjg:grid&gt;</code></p>
  
  <p><strong>I am not getting html values in alert inside function()</strong></p>