Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   export dataset to excel (http://www.velocityreviews.com/forums/t533470-export-dataset-to-excel.html)

=?Utf-8?B?TGFtaXM=?= 08-29-2007 12:04 PM

export dataset to excel
 
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.No Cache);
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

Mark Rae [MVP] 08-29-2007 12:15 PM

Re: export dataset to excel
 
"Lamis" <Lamis@discussions.microsoft.com> wrote in message
news:77B9A90D-5F6B-4E72-AEBF-83A1CD3DCAB0@microsoft.com...

> 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=?= 08-29-2007 12:32 PM

Re: export dataset to excel
 
hi mark
what should it be???
Response.charst = "ASCII" is not helping?
--
LZ


"Mark Rae [MVP]" wrote:

> "Lamis" <Lamis@discussions.microsoft.com> wrote in message
> news:77B9A90D-5F6B-4E72-AEBF-83A1CD3DCAB0@microsoft.com...
>
> > 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
>
>


Alexey Smirnov 08-29-2007 12:42 PM

Re: export dataset to excel
 
On Aug 29, 2:32 pm, Lamis <La...@discussions.microsoft.com> wrote:
> hi mark
> what should it be???
> Response.charst = "ASCII" is not helping?
> --
> LZ
>
>
>
> "Mark Rae [MVP]" wrote:
> > "Lamis" <La...@discussions.microsoft.com> wrote in message
> >news:77B9A90D-5F6B-4E72-AEBF-83A1CD3DCAB0@microsoft.com...

>
> > > 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)



Mark Rae [MVP] 08-29-2007 12:47 PM

Re: export dataset to excel
 
"Lamis" <Lamis@discussions.microsoft.com> wrote in message
news:31DE1826-8D1E-48C0-A890-ED432F6CEEC0@microsoft.com...

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


First, I would try:

Response.Charset = "iso-8859-1";

If that doesn't work, then try adding a ResponseEncoding tag to the @Page
directive e.g.

<%@ Page ContentType="text/html" ResponseEncoding="iso-8859-1">

See here:
http://www.experts-exchange.com/Prog..._21551614.html


--
Mark Rae
ASP.NET MVP
http://www.markrae.net


=?Utf-8?B?TGFtaXM=?= 08-29-2007 12:56 PM

Re: export dataset to excel
 
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 <La...@discussions.microsoft.com> wrote:
> > hi mark
> > what should it be???
> > Response.charst = "ASCII" is not helping?
> > --
> > LZ
> >
> >
> >
> > "Mark Rae [MVP]" wrote:
> > > "Lamis" <La...@discussions.microsoft.com> wrote in message
> > >news:77B9A90D-5F6B-4E72-AEBF-83A1CD3DCAB0@microsoft.com...

> >
> > > > 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)
>
>
>



All times are GMT. The time now is 07:55 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.