|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Export to excel problemI don't know why my program exports to excel which can't convert cell format ? for example, I am using the following code: Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment; filename=OutstandingOrderDetailReport.xls"); "OrderNo" field should be 00001234, but it can display 1234 in excel file. DataFormatString defined the following: <asp:boundcolumn headertext="OrderNo" datafield="OrderNo" DataFormatString="{0:0000000}"> <ItemStyle HorizontalAlign="Right"></ItemStyle> </asp:BoundColumn> Please advised. Hi Kelvin,
Actually I think it may be an Excel bug. When digital data, e.g. 00001234, is filled in a excel column, it automatically recognizes it as number, so trims its leading zero(s). If you use Excel automation COM object to deal with this kind of data, you can format the column as TEXT first, then fill up data. That will keep leading zero(s). However, I haven't found any way to figure it out in exporting datagrid to excel in ASP.NET. HTH Elton Wang elton_w***@hotmail.com >-----Original Message----- 1234 in excel>Hi All, > >I don't know why my program exports to excel which can't convert cell >format ? >for example, I am using the following code: >Response.ContentType = "application/vnd.ms-excel"; >Response.AddHeader("Content-Disposition", "attachment; >filename=OutstandingOrderDetailReport.xls"); > >"OrderNo" field should be 00001234, but it can display Show quoteHide quote >file. > >DataFormatString defined the following: ><asp:boundcolumn headertext="OrderNo" datafield="OrderNo" >DataFormatString="{0:0000000}"> ><ItemStyle HorizontalAlign="Right"></ItemStyle> ></asp:BoundColumn> > >Please advised. >. > one workaround is to append a quote before the string like so '00002034234.
The downside is that you would have to write iteration code to do that which can be a performance drain -- Show quoteHide quoteRegards, Alvin Bruney - ASP.NET MVP [Shameless Author Plug] The Microsoft Office Web Components Black Book with .NET Now available @ www.lulu.com/owc "Kelvin" <kelvin***@gmail.com> wrote in message news:db7965c.0504250023.31874121@posting.google.com... > Hi All, > > I don't know why my program exports to excel which can't convert cell > format ? > for example, I am using the following code: > Response.ContentType = "application/vnd.ms-excel"; > Response.AddHeader("Content-Disposition", "attachment; > filename=OutstandingOrderDetailReport.xls"); > > "OrderNo" field should be 00001234, but it can display 1234 in excel > file. > > DataFormatString defined the following: > <asp:boundcolumn headertext="OrderNo" datafield="OrderNo" > DataFormatString="{0:0000000}"> > <ItemStyle HorizontalAlign="Right"></ItemStyle> > </asp:BoundColumn> > > Please advised.
Paging with Datagrid Control
Change/read value from control in EditItemTemplate how can I get the DataKeyField TextBox Value MessageBox not showing before Response.Redirect ItemDataBound ItemCreated question Datagrid column formatting Need to create Hieararical DataGrid using ASP.Net Datagrid !!! button column |
|||||||||||||||||||||||