Hello good day! I have a webform application and I exported its content to an excel format. The language saved in my SQL Server is Lao script, but when I exported to excel it becomes unreadable. Below is the gridview before exporting to excel.
Below is the exported data in excel:
below is my code when exporting to excel:
- protected void btnExport_Click(object sender, EventArgs e)
- {
- Response.ClearContent();
- Response.AppendHeader("content-disposition", "attachment; filename=IssuedTaxInvoices.xls");
- Response.ContentType = "application/excel";
-
- StringWriter stringWriter = new StringWriter();
- Html32TextWriter htmlTextWriter = new Html32TextWriter(stringWriter);
-
-
- GridView1.HeaderRow.Style.Add("background-color", "#FFFFFF");
-
- foreach (TableCell tableCell in GridView1.HeaderRow.Cells)
- {
- tableCell.Style["background-color"] = "#000084";
- }
-
- foreach (GridViewRow gridViewRow in GridView1.Rows)
- {
- gridViewRow.BackColor = System.Drawing.Color.White;
- foreach (TableCell gridviewRowTableCell in gridViewRow.Cells)
- {
- gridviewRowTableCell.Style["background-color"] = "#EEEEEE";
- }
- }
-
- GridView1.FooterRow.Style.Add("background-color", "#FFFFFF");
-
- foreach (TableCell tableCell in GridView1.FooterRow.Cells)
- {
- tableCell.Style["background-color"] = "#CCCCCC";
- }
-
- foreach (GridViewRow gridViewRow in GridView1.Rows)
- {
- gridViewRow.BackColor = System.Drawing.Color.White;
- foreach (TableCell gridviewRowTableCell in gridViewRow.Cells)
- {
- gridviewRowTableCell.Style["background-color"] = "#EEEEEE";
- }
- }
-
-
-
- GridView1.RenderControl(htmlTextWriter);
- Response.Write(stringWriter.ToString());
- Response.End();
- }
thanks in advance for any help.