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
night sailor
NA
20
39.4k
Issue while exporting dataset to excel
Mar 14 2012 3:56 PM
Hi,
I have a dataset and i want to export it to excel. Problem is while one of the datacolumn contains negative value and i want that column value to be shown in brackets in excel.
In the dataset (datatable view) its getting displayed correctly. i.e. (21,000)
But in the excel, its ccoming as -21,000 but i want it in (21,000) format. Here is the piece of code which i am using...
*********************
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.Charset = string.Empty;
string filename = "test.xls";
response.ContentType = "application/vnd.ms-excel";
response.AddHeader(Constant.CONTENT_DISPOSITION, "attachment;filename=\"" + filename + "\"");
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid();
dg.Font.Name = "verdana";
dg.Font.Size = 10;
dg.HeaderStyle.Font.Bold = true;
dg.HeaderStyle.ForeColor = Color.SteelBlue;
dg.DataSource = DATASET;
dg.DataBind();
dg.RenderControl(htw);
response.Write(sw.ToString());
response.End();
}
}
**********************
Please suggest something...
Thanks.
Reply
Answers (
3
)
rounding to nearest .5
Vulpes your explanation needed