DateFormt To string format (Export To Excel)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Agnes

    #1

    DateFormt To string format (Export To Excel)

    dim strPeriod as string = dtTransdate.ToS tring("dd-MMM-yyyy",
    System.Globaliz ation.DateTimeF ormatInfo.Invar iantInfo)

    '--excel code
    ..Range("H2").V alue = 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").V alue = "'" & 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




  • +Vice

    #2
    Re: DateFormt To string format (Export To Excel)

    Why not format the whole column as text?

    "Agnes" <agnes@dynamict ech.com.hk> wrote in message
    news:uRW5giOaGH A.4036@TK2MSFTN GP04.phx.gbl...[color=blue]
    > dim strPeriod as string = dtTransdate.ToS tring("dd-MMM-yyyy",
    > System.Globaliz ation.DateTimeF ormatInfo.Invar iantInfo)
    >
    > '--excel code
    > .Range("H2").Va lue = 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").Va lue = "'" & 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
    >
    >
    >
    >[/color]


    Comment

    Working...