Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date To String (In Excel) problem
Message
 
À
26/04/2006 00:19:05
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01116547
Message ID:
01116656
Vues:
18
Hi Agnes

I believe that you ran in some Excel issues.

1. The way Excel treats dates is different from other languages. The date is represented internally as a number counted from the "Earliest date allowed January 1, 1900 (..... see other details in Excel Help)

2. Even you format the date to text with ' symbol, its value is still recognized in Excel as a date/number, and you can apply Excel date functions to it.
The only way I know to stop this behavior is to add another character in front of the date, like

.Range("H2").Value = " " & strPeriod
or
.Range("H2").Value = "''" & strPeriod



>dim strPeriod as string = dtTransdate.ToString("dd-MMM-yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo)
>
>'--excel code
>.Range("H2").Value = strPeriod
>
>When I read the excel, the column show "Apr-06" , seems correct , however ( it is a date format column), I try to change into string format in excel but still fail.
>
>Then , I try to put "'"
>.Range("H2").Value = "'" & strPeriod
>It is string format in Excel BUT when user do some sorting . (it change back into date format as shown as 01-Apr-2006 or 808354 (some strange integer)
>
>Please help
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform