Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 28th, 2004, 02:35 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default Exporting data from a repeater to an Excel sheet

I’m using this code to export data from a repeater to an Excel sheet:

Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=Clientes.xls");
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
Repeater1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();

Excel sheet when is displayed contains data from repeater, notwithstanding accents and Spanish letter ñ containing within data are not drawing correctly, e.g.:

México it is drawing as México
López it is drawing as López
Villafaña it is drawing as Villafaña
María it is drawing as MarÃa

¿Does somebody knows what is the reason about it and how can I fix it?


I’ll appreciate your help.

A.L.


El Hombre que tiene Amigos ha de mostrarse Amigo
__________________
El Hombre que tiene Amigos ha de mostrarse Amigo
 
Old January 11th, 2005, 03:51 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nobody have had an experience such this one?


El Hombre que tiene Amigos ha de mostrarse Amigo
 
Old January 12th, 2005, 01:27 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think you need to set the charset to something that supports your characterset.

Try this:

Response.Charset = "UTF-8";

or replace UTF-8 with another appropriate character set.

Cheers,

Imar
 
Old January 12th, 2005, 07:09 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks you Imar:
I already tried with "utf-8", "iso-latin-1", "iso-8859-1" and "unicode" and trouble is still there.
Yet if I replace repeater with a datagrid it works ok.
What a strange thing
A.L.

El Hombre que tiene Amigos ha de mostrarse Amigo
 
Old January 13th, 2005, 11:11 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

That's interesting. Apparently, there is built-in support for other charactersets in the DataGrid, and not in the Repeater.

Is using a DataGrid an option for you?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 14th, 2005, 01:03 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

May be use datagrid would be an option, but I'm confused about why it do not work with repeater.
Maybe cultural settings?
A.L.

El Hombre que tiene Amigos ha de mostrarse Amigo
 
Old January 17th, 2005, 01:19 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

At last I found the way to achieve it:

Below this line:

Response.ContentType = "application/vnd.ms-excel";

I insert this line :

Response.ContentEncoding = System.Text.Encoding.UTF7;

I hope this be useful people having a similar trouble.

A.L.


El Hombre que tiene Amigos ha de mostrarse Amigo
 
Old January 17th, 2005, 03:46 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Cool. Thanks for sharing. I am sure this can be useful.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting data to excel sheet x_ray VB.NET 2002/2003 Basics 0 January 6th, 2006 03:14 PM
reading data from excel sheet rajiv_software Classic ASP Basics 2 April 30th, 2005 01:03 AM
Query data and exporting data from one sheet to an testman Excel VBA 2 April 28th, 2005 02:40 PM
Exporting data from MS Excel sheet to Ms Access ajindal General .NET 1 January 17th, 2005 03:00 AM
Exporting to Excel - one sheet for many queries dearnne Access VBA 1 July 19th, 2004 09:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.