title: C#/Javascript datatable export to Excel and PDF
body: <p>I took over a C# Entity Framework project from an ex coworker. He set up a few tables in ways I am not to familiar using Javascript. I need to get the contents of this data table exported to an Excel and PDF file (seperate button for each). I am open to using C#, Javascript, or JQuery.</p>
  
  <p>I have been doing ColdFusion recently, and haven't even looked at anything .NET related in almost a year, so I am trying to get a refresher as well as figure out stuff I have never seen before, so my mind fried.</p>
  
  <p>Javascript Code used to fill the data table:
  </p>
  
  <pre><code>              $(document).ready(function () {
  
                    var active = true;
  
                    GetList(active);
                });
  
                function ChangeList() 
                {
                    GetList($("#ddlRiderType").val());
                }
  
                function GetList(isActive) {
  
                    $('#dataTable').dataTable({
                        "sDom": '&lt;"top"lf&gt;rt&lt;"bottom"ip&gt;&lt;"clear"&gt;',
                        "bAutoWidth": false,
                        "bProcessing": true,
                        "bSort": true,
                        "bDestroy": true,
                        "sPaginationType": "full_numbers",
                        "bServerSide": true,
                        "sAjaxSource": "Instructor.aspx/GetAllInstructors",
                        "fnServerData": function (sSource, aoData, fnCallback) {
  
                            var jsonData = "{jsonAOData : '" + JSON.stringify(aoData) + "', isActive: '" + isActive + "'}";
  
                            $.ajax({
                                //dataType: 'json', 
                                contentType: "application/json; charset=utf-8",
                                type: "POST",
                                url: sSource,
                                data: jsonData,
                                complete: function () { Init(); },
                                success: function (msg) {
                                    if (msg.d != null)
                                        fnCallback(msg.d);
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    ntfy_push("Error", ServerFail());
                                }
                            });
                        },
                        "aoColumnDefs": [
  
                  { "sName": "Cipher",
                      "aTargets": [0],
                      "bVisible": false,
                      "bSearchable": false
                  },
                  { "sName": "firstName",
                      "aTargets": [1]
                  },
                  { "sName": "lastName",
                      "aTargets": [2]
                  },
                  { "sName": "org",
                      "aTargets": [10]
                  },
                  { "sName": "workPhone",
                      "aTargets": [4]
                  },
                  { "sName": "altPhone",
                      "aTargets": [5],
                      "bVisible": false,
                      "bSearchable": false
                  },
                  { "sName": "cellPhone",
                      "aTargets": [6],
                      "bVisible": false,
                      "bSearchable": false
                  },
                   { "sName": "email",
                       "aTargets": [7]
                   },
                  { "sName": "riderCoach",
                      "aTargets": [8],
                      "bVisible": false,
                      "bSearchable": false
                  },
                  { "sName": "rangeAid",
                      "aTargets": [9],
                      "bVisible": false,
                      "bSearchable": false
                  },
                   { "sName": "admin",
                       "aTargets": [3]
                   },
                  { "sName": "seniorInst",
                      "aTargets": [11],
                      "bVisible": false,
                      "bSearchable": false
                  },
                  { "sName": "dateAdded",
                      "aTargets": [12],
                      "bVisible": false,
                      "bSearchable": false
                  },
                   { "sName": "dateMod",
                       "aTargets": [13],
                       "bVisible": false,
                       "bSearchable": false
                   },
                  { "sName": "modBy",
                      "aTargets": [14],
                      "bVisible": false,
                      "bSearchable": false
                  },
                  { "sName": "active",
                      "aTargets": [15],
                      "bVisible": false,
                      "bSearchable": false
                  },
                  { "sName": "delete",
                      "aTargets": [16],
                      "bVisible": false,
                      "bSearchable": false
                  },
                  { "fnRender": function () {
                      return "Edit";
                  },
                      "aTargets": [17]
                  },
                  { "fnRender": function () {
                      return "Delete";
                  },
                      "aTargets": [18]
                  }
              ],
                        "sDom": '&lt;"toolbar"&gt;flrtip'
                    });
  
                    $("div.toolbar").html("&lt;div class = 'tableOption'&gt;&lt;img src = 'image/button/new-icon.png'/ alt= 'Add New Class' style = 'cursor:pointer' onclick = 'Show_New_Instructor()'&gt;&lt;/div&gt;");
                }
  </code></pre>
  
  <p>Datatable used for the headers</p>
  
  <pre><code>&lt;table id = "dataTable"&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Instructor ID&lt;/th&gt;
          &lt;th&gt;First Name&lt;/th&gt;
          &lt;th&gt;Last Name&lt;/th&gt;
          &lt;th&gt;Admin&lt;/th&gt;
          &lt;th&gt;Work Phone&lt;/th&gt;
          &lt;th&gt;Alt Phone&lt;/th&gt;
          &lt;th&gt;Cell Phone&lt;/th&gt;
          &lt;th&gt;Email Address&lt;/th&gt;
          &lt;th&gt;Rider Coach&lt;/th&gt;
          &lt;th&gt;Range Aid&lt;/th&gt;
          &lt;th&gt;Organ&lt;/th&gt;
          &lt;th&gt;Senior Inst&lt;/th&gt;
          &lt;th&gt;Date Added&lt;/th&gt;
          &lt;th&gt;Date Modified&lt;/th&gt;
          &lt;th&gt;Mod By&lt;/th&gt;
          &lt;th&gt;Active&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  
  &lt;tbody&gt;&lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Excel Button:
      </p>
  
  <p>PDF Button:
      </p>
  
  <p>I thank you in advance for the help, and if this is already in a post somewhere I do apologize for overlooking it.</p>