Want to build the ChatGPT based Apps? Start here
Become a member
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
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Karthik K
1.8k
333
35.3k
Excel Export string column in asp.net ?
Feb 23 2020 11:50 PM
Hi All ,
I have issue on Excel Export. While I do have String Coulmn in database but which contains Number. While I export.its how some other formats.
8.00318E+12
How can I resolve this issue? I can show the code too. If anyone knows just suggest me with example.
The following code i just used in Excel Export ..
//Create a dummy GridView
GridView GridView1 =
new
GridView();
GridView1.ShowFooter =
true
;
GridView1.AllowPaging =
false
;
GridView1.DataSource = Dt2;
GridView1.DataBind();
Response.Clear();
Response.Buffer =
true
;
Response.AddHeader(
"content-disposition"
,
"attachment;filename=MemberHistory.xls"
);
Response.Charset =
""
;
Response.ContentType =
"application/vnd.ms-excel"
;
StringWriter sw =
new
StringWriter();
HtmlTextWriter hw =
new
HtmlTextWriter(sw);
for
(
int
i = 0; i < 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 = @
"<style> textmode { mso-number-format:General } </style>"
;
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
Thanks in Advance
Karthik K
Reply
Answers (
2
)
Count Register User web api.
Pdf bookmark removed after adding header using itextsharp