title: Export to excel file shows error
body: <p>I am trying to use a plugin that converts the posts of a blog to to .xls format. When i try to open the .xls file i get an error that file format is different or file is corrupt. This is the code for creating .xls file.</p>
  
  <pre><code>&lt;?php
    if (isset($_POST['Submit']) &amp;&amp; isset($_POST['post_type']) &amp;&amp;  isset($_POST['ext']) ) {
      $post_type = $_POST['post_type'];
      $ext = $_POST['ext'];
      $str = '';
      if ( is_multisite() ) {
        $blog_info = get_blog_list(0, 'all');
        foreach ($blog_info as $blog) {
          switch_to_blog($blog['blog_id']);
          include('loop.php');
          restore_current_blog();
        }
      } else {
        include('loop.php');
      }
      $filename = strtolower(str_replace(' ','-',get_bloginfo('name'))) .'-urls.' . $ext;
      header("Content-type: application/vnd.ms-excel;");
      header("Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, charset=utf-8;");
      header("Content-Disposition: attachment; filename=" . $filename);
  
      print $str;//$str variable is used in loop.php
      wp_redirect(admin_url('admin.php?page=../export-2-excel.php&amp;noheader=true'));
      exit();
    }
  ?&gt;
  </code></pre>
  
  <p>the code for loop.php is</p>
  
  <pre><code>&lt;?php
    if($post_type != 'comment_authors') {
      query_posts(array('posts_per_page' =&gt; -1, 'order'=&gt;'DESC', 'post_type' =&gt; $post_type));//-1 is for all posts
      $str .= '&lt;table&gt;
                &lt;tr&gt;
                  &lt;td colspan=7&gt;' . get_bloginfo('name').'
                &lt;/tr&gt;';
      if (have_posts()) {
        $str .= '&lt;tr&gt;
                  &lt;th&gt;Name&lt;/th&gt;
                  &lt;th&gt;Description&lt;/th&gt;
                  &lt;th&gt;Url&lt;/th&gt;
                  &lt;th&gt;Created on&lt;/th&gt;
                  &lt;th&gt;Author&lt;/th&gt;
                  &lt;th&gt;Categories&lt;/th&gt;
                  &lt;th&gt;Tags&lt;/th&gt;
                &lt;/tr&gt;';
        while (have_posts()) {
          the_post();
  
          $all_cats = '';
          foreach( (get_the_category()) as $category) {
            $all_cats .= $category-&gt;cat_name . ', ';
          }
          $all_cats = substr($all_cats, 0, -2);
  
  
          $all_tags = '';
          $posttags = get_the_tags();
          if ($posttags) {
            foreach( (get_the_tags()) as $tag) {
              $all_tags .= $tag-&gt;name . ', ';
            }
            $all_tags = substr($all_tags, 0, -2);
          }
          global $post;
  
          $str.= '
            &lt;tr&gt;
              &lt;td&gt;' . mb_convert_encoding(get_the_title(), 'HTML-ENTITIES', 'UTF-8') . '&lt;/td&gt;
              &lt;td&gt;' . mb_convert_encoding($post-&gt;post_content, 'HTML-ENTITIES', 'UTF-8') . '&lt;/td&gt;
              &lt;td&gt;' . get_permalink() .'&lt;/td&gt;
              &lt;td&gt;' . get_the_date('Y-m-d', '', '', FALSE) .'&lt;/td&gt;
              &lt;td&gt;' . get_the_author() .'&lt;/td&gt;
              &lt;td&gt;' . $all_cats . '&lt;/td&gt;
              &lt;td&gt;' . $all_tags . '&lt;/td&gt;
            &lt;/tr&gt;';
        }
        wp_reset_query();
      } else {
        $str .= '&lt;tr colspan="6"&gt;&lt;td&gt;No post found.&lt;/td&gt;&lt;/tr&gt;';
      }
      $str.= '&lt;/table&gt;&lt;br/&gt;&lt;/br&gt;';
    } else {
      global $wpdb,$table_prefix;
      $str .= '&lt;table&gt;
              &lt;tr&gt;
                &lt;td colspan=6&gt;' . get_bloginfo('name').'
              &lt;/tr&gt;';
      $str .= '&lt;tr&gt;
                &lt;th&gt;Commenter&lt;/th&gt;
                &lt;th&gt;Email Address&lt;/th&gt;
                &lt;th&gt;Url&lt;/th&gt;
                &lt;th&gt;Created on&lt;/th&gt;
                &lt;th&gt;IP Address&lt;/th&gt;
                &lt;th&gt;Comments&lt;/th&gt;
              &lt;/tr&gt;';
     $commenters = $wpdb-&gt;get_results("SELECT COUNT(comment_ID) AS count, comment_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_author_IP FROM $table_prefix"."comments WHERE comment_approved = 1 AND comment_type = '' GROUP BY comment_author, comment_author_email ORDER BY comment_author ASC, comment_date DESC;");
  
      foreach ($commenters as $row)
      {
        $str.= '&lt;tr&gt;
                 &lt;td&gt;'.$row-&gt;comment_author.'&lt;/td&gt;';
        $str.= '&lt;td&gt;'.$row-&gt;comment_author_email."&lt;/td&gt;";
        $str.= '&lt;td&gt;'.$row-&gt;comment_author_url."&lt;/td&gt;";
        $str.= '&lt;td&gt;'.$row-&gt;comment_date."&lt;/td&gt;";
        $str.= '&lt;td&gt;'.$row-&gt;comment_author_IP."&lt;/td&gt;";
        $str.= '&lt;td&gt;'.$row-&gt;count."&lt;/td&gt;
               &lt;/tr&gt;";
      }
    }
  </code></pre>
  
  <p>Is there something wrong while creating the .xls file? </p>