title: Read Chinese when export to excel
body: <p>I am using oracle database and asp.net 2013..</p>
  
  <p>code below is how I export my data from database to Excel file.</p>
  
  <pre><code>private DataTable GetData(string sqlcommand)
          {
              try
              { 
                  string sapno = "SAP NO";
                  string partno = "PART NO";
                  string partdesc = "PART DESCRIPTION";
                  string minQty = "MINIMUM QUANTITY";
                  string QOH = "QUANTITY ON HAND";
                  string category = "CATEGORY";
                  string equipment = "EQUIPMENT";
  
                  readdata.selectdata(ds, sqlcommand);
                  DataTable dt = ds.Tables[0];
                  dt.Columns[0].ColumnName = sapno;
                  dt.Columns[1].ColumnName = partno;
                  dt.Columns[2].ColumnName = partdesc;
                  dt.Columns[3].ColumnName = minQty;
                  dt.Columns[4].ColumnName = QOH;
                  dt.Columns[5].ColumnName = category;
                  dt.Columns[6].ColumnName = equipment;
                  ds.Tables.Clear();
                  return dt;
              }
              catch (Exception ex)
              {
                  throw ex;
              } 
          }
  
          protected void btnDownload_Click(object sender, EventArgs e)
          {
              //Get the data from database into datatable
              string sqlcommand=null;
  
              if (validate.isEmpty(txtPartNo.Text) == true || Session["SAPNOIR"] ==null)
              {
                  sqlcommand = "SELECT SAPNO , PARTNO, PARTDESC, MINQTY, QOH , CATEGORY, EQUIPMENT FROM INVENTORY";
              }
              else
              {
                  sqlcommand = "SELECT SAPNO, PARTNO, PARTDESC, MINQTY, QOH , CATEGORY, EQUIPMENT FROM INVENTORY WHERE SAPNO = '" + Session["SAPNOIR"] + "'";
                  Session["SAPNOIR"] = null;
              }
  
              DataTable dt = GetData(sqlcommand);
  
              //Create a dummy GridView
              GridView GridView1 = new GridView();
              GridView1.AllowPaging = false;
              GridView1.DataSource = dt;
              GridView1.DataBind();
  
              Response.Clear();
              Response.Buffer = true;
              Response.AddHeader("content-disposition",
               "attachment;filename=DataTable.xls");
              Response.Charset = "";
              Response.ContentType = "application/vnd.ms-excel";
              StringWriter sw = new StringWriter();
              HtmlTextWriter hw = new HtmlTextWriter(sw);
  
              for (int i = 0; i &lt; GridView1.Rows.Count; i++)
              {
                  //Apply text style to each Row
                  GridView1.Rows[i].Attributes.Add("class", "textmode");
              }
              GridView1.RenderControl(hw);
  
              //style to format numbers to string
              string style = @"&lt;style&gt; .textmode { mso-number-format:\@; } &lt;/style&gt;";
              Response.Write(style);
              Response.Output.Write(sw.ToString());
              Response.Flush();
              Response.End();
          }
  </code></pre>
  
  <p>when I open the excel file, all the chinese character will become unreadable character. anyone know how I can show chinese character when export to excel file!!</p>
  
  <p>I do try add encoding window 1250 in my web.config but it stil not working.
  Anyone please do help. thanks</p>
  
  <p>Thanks for your comment is suggestion! its much appreaciated!</p>