title: exclude hidden columnname and corresponding colmodel from exporting to excel
body: <p>Guys I need some help here. I have hidden colModel in jqgird when I export my grid in excel I am getting all the data including hidden ones. So my requirement is not to display any hidden column name and corresponding colmodel while doing export. The colModel firstValue and secondVlaue have property hidden= true and I need It(columnname and cell value) to not appear in excel if its hidden. can you please provide me some guidance/suggestion as how this can be achieved.  It's been 3 days and I can't figure out how this can be achieved. Any help will be highly appreciated.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>grid = jQuery("#list2");
                  grid.jqGrid({
                      datastr : comparePatchData,
                      datatype: 'jsonstring',
                      colNames:['Name',starheader, header1, header2],
                      colModel:[
                          {name:'elementName',index:'elementName', width:90},
                          {name:'isPrasentinXml1',index:'isPrasentinXml1', width:100, align:'center', formatter: patchPresent},
                          {name:'isPrasentinXml2',index:'isPrasentinXml2', width:100, align:'center', formatter: patchPresent},
                          {name:'isPrasentinXml3',index:'isPrasentinXml3', width:100, align:'center', formatter: patchPresent}
                      ],
                      pager : '#gridpager2',
                      rowNum:12,
                      scrollOffset:0,
                      height: 320,
                      autowidth:true,
                      viewrecords: true,
                      gridview: true,
                      loadonce:true,
                      jsonReader: {
                          repeatitems: false,
                          page: function() { return 1; },
                          root: "response"
                      },
                      subGrid: true,
                      // define the icons in subgrid
                      subGridOptions: {
                          "plusicon"  : "ui-icon-triangle-1-e",
                          "minusicon" : "ui-icon-triangle-1-s",
                          "openicon"  : "ui-icon-arrowreturn-1-e",
                          //expand all rows on load
                          "expandOnLoad" : false
                      },
  
                      subGridRowExpanded: function(subgrid_id, row_id) {
                          //console.info(subgrid_id+", "+row_id);
                          var subgrid_table_id, pager_id, iData = -1;
                          subgrid_table_id = subgrid_id+"_t";
                          //pager_id = "p_"+subgrid_table_id;
                          $("#"+subgrid_id).html("&lt;table id='"+subgrid_table_id+"' style='overflow-y:auto' class='scroll'&gt;&lt;/table&gt;&lt;div id='"+pager_id+"' class='scroll'&gt;&lt;/div&gt;");
  
                          $.each(comparePatchData.response,function(i,item){
                              if(item.id === row_id) {
                                  iData = i;
                                  return false;
                              }
  
                          });
                          if (iData == -1) {
                              return; // no data for the subgrid
                          }
  
                          jQuery("#"+subgrid_table_id).jqGrid({
                              datastr : comparePatchData.response[iData],
                              datatype: 'jsonstring',
                              colNames: ['Name','Value1','Value2','Value3'],
                              colModel: [
                                  {name:"name",index:"name",width:90},
                                  {name:"firstValue",index:"firstValue",width:100, hidden:true},
                                  {name:"secondValue",index:"secondValue",width:100, hidden:true},
                                  {name:"thirdValue",index:"thirdValue",width:100}
                              ],
                              rowNum:10,
                              //pager: pager_id,
                              sortname: 'name',
                              sortorder: "asc",
                              height: 'auto',
                              autowidth:true,
                              jsonReader: {
                                  repeatitems: false,
                                  //page: function() { return 1; },
                                  root: "attribute"
                              }
                          });
  
                          jQuery("#"+subgrid_table_id).jqGrid('navGrid',{edit:false,add:false,del:false});
                      }
                  });
                  grid.jqGrid('navGrid','#gridpager2',{add:false,edit:false,del:false});
                  grid.jqGrid('navButtonAdd','#gridpager2',{
                      caption:"Export to Excel", 
                      onClickButton : function () { 
                          jQuery("#list2").excelExport();
                      } 
                  });
                  
                  
                  
  //response
  
  {
  "response": [
      {
          "id": "1",
          "elementName": "libgtop2-devel-2.14.4-3.el5",
          "subCategory": "patch",
          "isEqual": false,
          "isPrasentinXml1": false,
          "isPrasentinXml2": false,
          "isPrasentinXml3": true,
          "attribute": [
              {
                  "name": "name",
                  "thirdValue": "libgtop2-devel-2.14.4-3.el5"
              }
          ]
      },
      {
          "id": "2",
          "elementName": "ifd-egate-0.05-15",
          "subCategory": "patch",
          "isEqual": false,
          "isPrasentinXml1": false,
          "isPrasentinXml2": false,
          "isPrasentinXml3": true,
          "attribute": [
              {
                  "name": "name",
                  "thirdValue": "ifd-egate-0.05-15"
              }
          ]
      }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>var response = JSON.parse(responseJSON).response;
  var csv = arrayToCSV(response);
  
  function arrayToCSV(arr) {
      var columnNames = [];
      var rows = [];
      for (var i=0, len=arr.length; i&lt;len; i++) {
          // Each obj represents a row in the table
          var obj = arr[i];
          // row will collect data from obj
          var row = [];
          for (var key in obj) {
              // Don't iterate through prototype stuff
              if (!obj.hasOwnProperty(key)) continue;
              // Collect the column names only once
              if (i === 0) columnNames.push(prepareValueForCSV(key));
              // Collect the data
              row.push(prepareValueForCSV(obj[key]));
          }
          // Push each row to the main collection as csv string
          rows.push(row.join(','));
      }
      // Put the columnNames at the beginning of all the rows
      rows.unshift(columnNames.join(','));
      // Return the csv string
      return rows.join('\n');
  }
  
  // This function allows us to have commas, line breaks, and double 
  // quotes in our value without breaking CSV format.
  function prepareValueForCSV(val) {
      val = '' + val;
      // Escape quotes to avoid ending the value prematurely.
      val = val.replace(/"/g, '""');
      return '"' + val + '"';
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="test" &gt;
    &lt;table id="list2"&gt;&lt;/table&gt;
   &lt;/div&gt;
    {</code></pre>
  </div>
  </div>
  </p>