TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jes Sie
737
1.2k
284.6k
Language output is not correct when exporting to excel
Sep 3 2017 12:15 AM
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);
//Below code will format the color only to the affected area
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"
;
}
}
//formatting of color ends here
GridView1.RenderControl(htmlTextWriter);
Response.Write(stringWriter.ToString());
Response.End();
}
thanks in advance for any help.
Reply
Answers (
2
)
Difference between RDL and RDLC file in visual studio??????
Error message on deployment to IIS 8,5