Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 28th, 2004, 02:35 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
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
  #2 (permalink)  
Old January 11th, 2005, 03:51 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
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
  #3 (permalink)  
Old January 12th, 2005, 01:27 PM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,050
Thanks: 80
Thanked 1,581 Times in 1,558 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
  #4 (permalink)  
Old January 12th, 2005, 07:09 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
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
  #5 (permalink)  
Old January 13th, 2005, 11:11 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,050
Thanks: 80
Thanked 1,581 Times in 1,558 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.
  #6 (permalink)  
Old January 14th, 2005, 01:03 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
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
  #7 (permalink)  
Old January 17th, 2005, 01:19 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
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
  #8 (permalink)  
Old January 17th, 2005, 03:46 PM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,050
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

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

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


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 02:03 AM
Query data and exporting data from one sheet to an testman Excel VBA 2 April 28th, 2005 03: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 10:39 AM



All times are GMT -4. The time now is 09:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.