Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 16th, 2010, 11:00 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default Excel output question

Afternoon - I am outputting data to a .xls file. The method I am using is simply adding:

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

To the head of my .asp page. I would like this particular column to look like this (actual values):

23/10
8/10
43/10
9/10
25/10

However Excel is trying to be a bit smart and convert these to dates therefore my output when opened inside Excel is:

23-Oct (incorrect)
8-Oct (incorrect)
43/10 Correct
9-Oct (incorrect)
25-Oct (incorrect)

Any ideas how I can fix this inside the .ASP file so the these values do not get converted??

TYIA

Note - If I surrounf the value in double quotes inside the .asp page this works but of course the values have the double quotes around them in the .xls file which I would rather not see...
__________________
Wind is your friend
Matt

Last edited by mat41; November 16th, 2010 at 11:02 PM..
Reply With Quote
  #2 (permalink)  
Old November 17th, 2010, 06:08 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

It's a mild hack, but if you put in a dummy second row (the first row will be the column titles, of course) with something that is obviously *NOT* a date, Excel might get it right.

Maybe you could have a second row that would be sub-titles. You and human users would know they were sub-titles, but Excel might take them as data.
Reply With Quote
  #3 (permalink)  
Old November 17th, 2010, 06:27 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Hi there - I will give that a go to see if it works however I think the client would want me to hide the row if it worked. Any trick you knwo of to hide it/other ideas?
__________________
Wind is your friend
Matt
Reply With Quote
  #4 (permalink)  
Old November 17th, 2010, 06:46 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

How about using a row of dashes? So it looks like a separator line?

Or maybe put Chr(160) in each cell? (That *should* show up as a space character...it's what   is converted to in the browser.)

Or or or...

Hey, if Chr(160) works, you could prefix each of the fractions with it, maybe??
Reply With Quote
The Following User Says Thank You to Old Pedant For This Useful Post:
mat41 (November 17th, 2010)
  #5 (permalink)  
Old November 17th, 2010, 08:40 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Yes yes very excellent!! Chr(160) as a prefix worked like a charm. As always thank you for your time and excellence!!
__________________
Wind is your friend
Matt
Reply With Quote
  #6 (permalink)  
Old November 17th, 2010, 09:19 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Sometimes I get lucky. <grin/> I was trying to figure out some innocuous character that you could throw in there that wouldn't muck up the display but would prevent Excel from seeing anything resembling a date. And I just happened to remember that I once copy/pasted one of those &nbsp; into VBScript and did (essentially) <%=Asc("&nbsp;")%> and it came out as 160. Voila.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
ASP to Excel - excel output formatting issue mat41 Classic ASP Professional 0 August 13th, 2006 06:41 AM
Output to Excel rgerald SQL Server 2000 9 July 7th, 2005 09:42 AM
About output data to excel momowu0701 Beginning VB 6 0 March 1st, 2005 09:31 AM
Output page cache question flyin General .NET 0 September 11th, 2004 04:38 PM
Displaying output in Excel via ASP Sach Classic ASP Components 4 May 3rd, 2004 07:37 AM



All times are GMT -4. The time now is 08:17 PM.


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