Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Export to Excel Date Format for UK

Export to Excel Date Format for UK

Scheduled Pinned Locked Moved ASP.NET
wpfwcfhelpquestionlearning
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thowra
    wrote on last edited by
    #1

    Hi, My web application exports a List of objects to an Excel spreadsheet by creating a DataGrid and binding it to the List. The objects that the List contains include columns whose type is DateTime and while the resulting spreadsheet correctly lists all the objects, the date format is US instead of UK (which is what I want) - to be expected really. I can, of course, create a new object class and copy each object in the List to a second List of these new object types and bind the DataGrid to that but I'll have to do the same for every list of object types I want to export. Can anyone suggest a simple method to resolve this issue? Thanks :)

    Evil cannot be conquered in the world... It can only be resisted within oneself.

    T 1 Reply Last reply
    0
    • T thowra

      Hi, My web application exports a List of objects to an Excel spreadsheet by creating a DataGrid and binding it to the List. The objects that the List contains include columns whose type is DateTime and while the resulting spreadsheet correctly lists all the objects, the date format is US instead of UK (which is what I want) - to be expected really. I can, of course, create a new object class and copy each object in the List to a second List of these new object types and bind the DataGrid to that but I'll have to do the same for every list of object types I want to export. Can anyone suggest a simple method to resolve this issue? Thanks :)

      Evil cannot be conquered in the world... It can only be resisted within oneself.

      T Offline
      T Offline
      thowra
      wrote on last edited by
      #2

      Simplest method turned out to be iterating through the list, parsing any DateTime fields with the DateTime.Parse() method specifying "en-GB" CultureInfo as the DateTimeFormat parameter :cool:

      Evil cannot be conquered in the world... It can only be resisted within oneself.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups