title: Export tables to excel, including a macro
body: <p>For statistical reasons, I want an extensive analysis from a dataset. I already have a function that exports the data to Excel, but I have raw data that way; 500 lines, 35 columns, heaps of text sometimes... </p>
  
  <p>Is it possible to include a macro into a function so that the excelfile is readymade to be analyzed?</p>
  
  <p>I am using ASP, Javascript, and at the moment Excel 2003.
  This is the current function (written by one of my predecessors): </p>
  
  <pre><code>    function exporttoexcel()
      { //export to excel
          if (tableSortArray.length &gt; 0)
          { 
            var t, arr;
            var tempArray=new Array();
  
            for(var i=0; i, i&lt;tableSortArray.length; i++) {
                arr = tableSortArray[i].toString();
                arrr = (arr.split(","));
                if (i==0) { t = arrr[1]; }
                else { t += ','+arrr[1]; }
            }
            document.excel.t.value = t;
          }
          // I left out some mumbojumbo about sorting here
          document.excel.submit();
  }
  </code></pre>
  
  <p>I mean macro's so that graphs are made "automatically" as well as some turntables... </p>