I don't have code in front of me to explain in detail, but can't you
step through the dataset and add some sort of String.Format (assuming
you're using C# here - it looks like you are)?

Example for string format.
http://stackoverflow.com/questions/418822/asp-net-negative-numbers-in-parenthesis

Examples for cycling through dataset
http://bytes.com/topic/c-sharp/answers/251798-loop-through-dataset-get-values-vb-net
http://social.msdn.microsoft.com/Forums/zh/csharpgeneral/thread/0866d84c-b22c-4d68-9769-b51eb2d3955a

A few minutes of Google search may very well help you in this case.

FYI: if you're passing this dataset to a gridview of some sort, you
may very well be able to export the gridview itself, and do all your
formatting on the gridview - which sounds like you're doing that
already.

On Mar 14, 3:22 pm, Himanshu Jain <[email protected]> wrote:
> 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 coming 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.

-- 
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net

Reply via email to