Export to excel problem

Discussion in 'ASP .Net Datagrid Control' started by Kelvin, Apr 25, 2005.

  1. Kelvin

    Kelvin Guest

    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.
    Kelvin, Apr 25, 2005
    #1
    1. Advertising

  2. Kelvin

    Elton W Guest

    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




    >-----Original Message-----
    >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.
    >.
    >
    Elton W, Apr 25, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2aWQgVmFsbGU=?=

    Invalid export DLL or export format

    =?Utf-8?B?RGF2aWQgVmFsbGU=?=, Oct 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,617
    =?Utf-8?B?RGF2aWQgVmFsbGU=?=
    Oct 29, 2003
  2. =?Utf-8?B?U3JpZGhhcg==?=

    using Microsoft Excel image for Export to Excel button

    =?Utf-8?B?U3JpZGhhcg==?=, Dec 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    3,102
    =?Utf-8?B?U3JpZGhhcg==?=
    Dec 9, 2005
  3. =?Utf-8?B?SGVtYW50IFNpcGFoaW1hbGFuaQ==?=

    Export to Excel (Default File Type - Excel)

    =?Utf-8?B?SGVtYW50IFNpcGFoaW1hbGFuaQ==?=, Apr 24, 2006, in forum: ASP .Net
    Replies:
    15
    Views:
    17,517
    syed hassan
    May 21, 2009
  4. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,499
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  5. Grey
    Replies:
    4
    Views:
    1,967
    Mark Rae [MVP]
    Oct 17, 2007
Loading...

Share This Page