Wrox Programmer Forums
|
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 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 November 16th, 2010, 11:00 PM
Friend of Wrox
 
Join Date: Jan 2004
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..
 
Old November 17th, 2010, 06:08 PM
Friend of Wrox
 
Join Date: Jun 2008
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.
 
Old November 17th, 2010, 06:27 PM
Friend of Wrox
 
Join Date: Jan 2004
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
 
Old November 17th, 2010, 06:46 PM
Friend of Wrox
 
Join Date: Jun 2008
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??
The Following User Says Thank You to Old Pedant For This Useful Post:
mat41 (November 17th, 2010)
 
Old November 17th, 2010, 08:40 PM
Friend of Wrox
 
Join Date: Jan 2004
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
 
Old November 17th, 2010, 09:19 PM
Friend of Wrox
 
Join Date: Jun 2008
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.





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





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