title: Export html table to excel with Spanish characters
body: <p>I am using a script with the help of JQUERY to export html table into excel. The problem is that the html page contains some Spanish characters with accents which are not getting encoded correctly inside the Excel file. But on the html file they are fine. </p>
  
  <p>Here is my html page script: </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
      &lt;html lang="es"&gt;
        &lt;head&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form action="exporttoexcel.php" method="post" 
  onsubmit='$("#datatodisplay").val( $("&lt;div&gt;").append( $("#ReportTable").eq(0).clone() ).html() )'&gt;
    &lt;table id="ReportTable" width="600" cellpadding="2" cellspacing="2" class="myClass"&gt;
      &lt;tr&gt;
        &lt;th&gt;First Name&lt;/th&gt;
        &lt;th&gt;Last Name&lt;/th&gt;
        &lt;th&gt;Country&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;center&gt;
            investigación
          &lt;/center&gt;&lt;/td&gt;
        &lt;td&gt;&lt;center&gt;
            investigación
          &lt;/center&gt;&lt;/td&gt;
        &lt;td&gt;&lt;center&gt;
            investigación
          &lt;/center&gt;&lt;/td&gt;
      &lt;/tr&gt;   
    &lt;/table&gt;
    &lt;table width="600px" cellpadding="2" cellspacing="2" border="0"&gt;
      &lt;tr&gt;
        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td align="center"&gt;&lt;input type="hidden" id="datatodisplay" name="datatodisplay"&gt;
          &lt;input type="submit" value="Export to Excel"&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>and the php form processing code is the following: </p>
  
  <pre><code>&lt;?php
  header("Pragma: no-cache");
  header('Content-Encoding: UTF-8');
  header('Content-Type: application/force-download; charset=utf-8');
  header('Content-disposition: attachment; filename=export.xls');
  // Fix for IE bug in download.
  header("Pragma: ");
  header("Cache-Control: ");
  echo $_REQUEST['datatodisplay'];
  ?&gt;
  </code></pre>
  
  <p>Any help resolving this situation is welcome. Thanks!</p>