export dataset to excel

Discussion in 'ASP .Net' started by =?Utf-8?B?TGFtaXM=?=, Aug 29, 2007.

  1. Hello,

    I have a dataset that has information written in Swedish language, that
    means alot of stranch chars like 'Å, Ä, Ö' etc and my code
    void Export(datagrid myDataGrid){
    Response.Clear();

    Response.AddHeader("content-disposition","attachment;filename=FileName.xls");
    Response.Charset = "";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ContentType = "application/vnd.xls";
    System.IO.StringWriter stringWrite = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
    myDataGrid.RenderControl(htmlWrite);
    Response.Write(stringWrite.ToString());
    Response.End();}
    this exports a file and replaces the swedish chars to something else like
    ö.. Do you have any code sample or idea how to fix that???
    --
    LZ
    =?Utf-8?B?TGFtaXM=?=, Aug 29, 2007
    #1
    1. Advertising

  2. "Lamis" <> wrote in message
    news:...

    > Response.Charset = "";


    Is that not the problem...? Don't you have to specify a value for Charset
    here...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Aug 29, 2007
    #2
    1. Advertising

  3. hi mark
    what should it be???
    Response.charst = "ASCII" is not helping?
    --
    LZ


    "Mark Rae [MVP]" wrote:

    > "Lamis" <> wrote in message
    > news:...
    >
    > > Response.Charset = "";

    >
    > Is that not the problem...? Don't you have to specify a value for Charset
    > here...?
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >
    =?Utf-8?B?TGFtaXM=?=, Aug 29, 2007
    #3
  4. On Aug 29, 2:32 pm, Lamis <> wrote:
    > hi mark
    > what should it be???
    > Response.charst = "ASCII" is not helping?
    > --
    > LZ
    >
    >
    >
    > "Mark Rae [MVP]" wrote:
    > > "Lamis" <> wrote in message
    > >news:...

    >
    > > > Response.Charset = "";

    >
    > > Is that not the problem...? Don't you have to specify a value for Charset
    > > here...?

    >
    > > --
    > > Mark Rae
    > > ASP.NET MVP
    > >http://www.markrae.net- Hide quoted text -

    >
    > - Show quoted text -


    Hej Lamis

    try to set encoding

    Response.ContentEncoding = System.Text.Encoding.GetEncoding(1252)
    Alexey Smirnov, Aug 29, 2007
    #4
  5. Mark Rae [MVP], Aug 29, 2007
    #5
  6. hi,

    Response.ContentEncoding = System.Text.Encoding.GetEncoding(1252) worked
    perfectly.. thank's ALOT for your help
    --
    LZ


    "Alexey Smirnov" wrote:

    > On Aug 29, 2:32 pm, Lamis <> wrote:
    > > hi mark
    > > what should it be???
    > > Response.charst = "ASCII" is not helping?
    > > --
    > > LZ
    > >
    > >
    > >
    > > "Mark Rae [MVP]" wrote:
    > > > "Lamis" <> wrote in message
    > > >news:...

    > >
    > > > > Response.Charset = "";

    > >
    > > > Is that not the problem...? Don't you have to specify a value for Charset
    > > > here...?

    > >
    > > > --
    > > > Mark Rae
    > > > ASP.NET MVP
    > > >http://www.markrae.net- Hide quoted text -

    > >
    > > - Show quoted text -

    >
    > Hej Lamis
    >
    > try to set encoding
    >
    > Response.ContentEncoding = System.Text.Encoding.GetEncoding(1252)
    >
    >
    >
    =?Utf-8?B?TGFtaXM=?=, Aug 29, 2007
    #6
    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?YWQ=?=
    Replies:
    1
    Views:
    838
    Steve C. Orr [MVP, MCSD]
    Oct 6, 2004
  2. Luis Esteban Valencia

    How to export a dataset to excel?

    Luis Esteban Valencia, Nov 3, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,957
    =?Utf-8?B?dmluYXk=?=
    Nov 3, 2004
  3. =?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,078
    =?Utf-8?B?U3JpZGhhcg==?=
    Dec 9, 2005
  4. =?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,461
    syed hassan
    May 21, 2009
  5. Sachin Salgarkar

    Export DataSet/ XML as Excel Sheet

    Sachin Salgarkar, Aug 4, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    7,532
    ritzkandy
    Sep 11, 2008
Loading...

Share This Page