title: How to fit <td> width to content when exporting to XLS cell
body: <p>I have a code that converts HTML tables to XLS format like this:</p>
  
  <pre><code>$fileNameXls = 'report.xls'; 
  $result = "
  &lt;table&gt;
    &lt;tr&gt;
      &lt;th&gt;Brand&lt;/th&gt;
      &lt;th&gt;Heroes&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; Marvel &lt;/td&gt;
      &lt;td&gt; Spiderman, Batman, Power Ranger, Power Puffgirl, and booya &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  ";
  
  
  $result = $header.$body;
  header("Content-type: application/vnd.ms-excel");
  header("Content-Disposition: attachment; filename=$fileNameXls");
  echo $result;
  </code></pre>
  
  <p>The problem is, when I open the XLS file the cell that contains the row in the HTML table seems to have a fixed width, and the width is not following the row content width, so it becomes overlapped like this:</p>
  
  <p><a href="https://i.stack.imgur.com/k9Zaw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k9Zaw.png" alt="example"></a></p>