title: return File (memory stream) encoding
body: <p>Hi I have problem to return right encoded file. </p>
  
  <p><code>finalString</code>  is here only for my control of encoding and show me right strings, but returned excel file dont contain right czech characters... (Č č š Š Ž etc...) Can someone help me?</p>
  
  <pre><code> byte[] bytes = encode.GetBytes(str.ToString());
   string finalString = encode.GetString(bytes);
  </code></pre>
  
  <p>Here is complete class:</p>
  
  <pre><code>public async Task&lt;IActionResult&gt; ExportExcel()
      {
         // List&lt;Material&gt; obj = new List&lt;Material&gt;();
         // obj = await _context.Material.ToListAsync();
  
          StringBuilder str = new StringBuilder();
          str.Append("&lt;table border=`" + "1px" + "`b&gt;");
          str.Append("&lt;tr&gt;");
          str.Append("&lt;td&gt;&lt;b&gt;Id&lt;/b&gt;&lt;/td&gt;");
          str.Append("&lt;td&gt;&lt;b&gt;Name&lt;/b&gt;&lt;/td&gt;");
          str.Append("&lt;/tr&gt;");
  
        //  foreach (Material val in obj)
         // {
              str.Append("&lt;tr&gt;");
              str.Append("&lt;td&gt;" + "0" + "&lt;/td&gt;");
              str.Append("&lt;td&gt;" + Česnek + "&lt;/td&gt;");
              str.Append("&lt;td&gt;&lt;font face=Arial Narrow size=" + "14px" + "&gt;" + val.Name.ToString() + "&lt;/font&gt;&lt;/td&gt;");
              str.Append("&lt;/tr&gt;");
         // }
  
          str.Append("&lt;/table&gt;");
  
  
          string uc = Configuration.UserCulture;
          int codepage =  1250; // _cultureDataProvider.GetAnsiCodePage(uc);
          Encoding encode = Encoding.GetEncoding(codepage);
  
          byte[] bytes = encode.GetBytes(str.ToString());
          string finalString = encode.GetString(bytes);
          MemoryStream stream = new MemoryStream(bytes);
  
          return File(stream, "application/vnd.ms-excel", "excel.xls");
  
  
          /*
          HttpContext.Response.Headers.Add("content-disposition", "attachment; filename=Information" + DateTime.Now.Year.ToString() + ".xls");
          this.Response.ContentType = "application/vnd.ms-excel";
          byte[] temp = System.Text.Encoding.ASCII.GetBytes(str.ToString());
          return File(temp, "application/vnd.ms-excel");
          */
      }
  </code></pre>