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. General Programming
  3. Visual Basic
  4. Date Formating getting changed when Converting MSFlexgrid content to Excel

Date Formating getting changed when Converting MSFlexgrid content to Excel

Scheduled Pinned Locked Moved Visual Basic
helpcssdatabasetutorial
5 Posts 3 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.
  • A Offline
    A Offline
    aaraaayen
    wrote on last edited by
    #1

    Hi All, In my vb application, I am generating data from database and retriving it and placing it in MSFlexgrid which includes date column also. And I am using the following code to convert the data from MSFlexgrid to Excel. But in that, in Date column is in properly coming in MSFlexgrid. But when we convert it to Excel, some of the dates (like 12/03/2008, 11/03/2008,04/03,2008..I hope all the dates less than or equal to 12) will be converted like 03/12/2008, 03/04/2008, 03/11/2008...like this. But the other dates 25/03/2008...is populating in Excel correctly. Please help me how to overcome this issue. Dim xlObject As Excel.Application Dim xlWB As Excel.Workbook Set xlObject = New Excel.Application 'This Adds a new woorkbook, you could open the workbook from file also Set xlWB = xlObject.Workbooks.Add Clipboard.Clear 'Clear the Clipboard With MSFlexGrid1 'Select Full Contents (You could also select partial content) .Col = 0 'From first column .Row = 0 'From first Row (header) .ColSel = .Cols - 1 'Select all columns .RowSel = .Rows - 1 'Select all rows Clipboard.SetText .Clip 'Send to Clipboard End With With xlObject.ActiveWorkbook.ActiveSheet .Range("b2").Select 'Select Cell A1 (will paste from here, to different cells) .Paste 'Paste clipboard contents End With ' This makes Excel visible xlObject.Visible = True Thanks in Advance, Regards, R. Sangeetha Priya

    P 2 Replies Last reply
    0
    • A aaraaayen

      Hi All, In my vb application, I am generating data from database and retriving it and placing it in MSFlexgrid which includes date column also. And I am using the following code to convert the data from MSFlexgrid to Excel. But in that, in Date column is in properly coming in MSFlexgrid. But when we convert it to Excel, some of the dates (like 12/03/2008, 11/03/2008,04/03,2008..I hope all the dates less than or equal to 12) will be converted like 03/12/2008, 03/04/2008, 03/11/2008...like this. But the other dates 25/03/2008...is populating in Excel correctly. Please help me how to overcome this issue. Dim xlObject As Excel.Application Dim xlWB As Excel.Workbook Set xlObject = New Excel.Application 'This Adds a new woorkbook, you could open the workbook from file also Set xlWB = xlObject.Workbooks.Add Clipboard.Clear 'Clear the Clipboard With MSFlexGrid1 'Select Full Contents (You could also select partial content) .Col = 0 'From first column .Row = 0 'From first Row (header) .ColSel = .Cols - 1 'Select all columns .RowSel = .Rows - 1 'Select all rows Clipboard.SetText .Clip 'Send to Clipboard End With With xlObject.ActiveWorkbook.ActiveSheet .Range("b2").Select 'Select Cell A1 (will paste from here, to different cells) .Paste 'Paste clipboard contents End With ' This makes Excel visible xlObject.Visible = True Thanks in Advance, Regards, R. Sangeetha Priya

      P Offline
      P Offline
      Prakash_Mishra
      wrote on last edited by
      #2

      hi the way u r submitting the date and retrieving it may be there is the problem try this it may help Dim signDate As String = Format(DateTimePicker2.Value, "MM/dd/yyyy") Regards

      Prakash Mishra(Banglore,India)

      A 1 Reply Last reply
      0
      • P Prakash_Mishra

        hi the way u r submitting the date and retrieving it may be there is the problem try this it may help Dim signDate As String = Format(DateTimePicker2.Value, "MM/dd/yyyy") Regards

        Prakash Mishra(Banglore,India)

        A Offline
        A Offline
        aaraaayen
        wrote on last edited by
        #3

        Hi, Thanks. The date is getting saved in "dd/mm/yyyy" format in database as well as its populating in msflexgrid in dd/mm/yyyy format. But when try to convert it to excel, in this case only some of the dates formating is changed. Especially the dates from 1-12 is getting interchanged the month and date places. Please help me how to format the cell so that it gets only in dd/mm/yyyy format, or suggest me some ideas to overcome this. Regards,

        A 1 Reply Last reply
        0
        • A aaraaayen

          Hi, Thanks. The date is getting saved in "dd/mm/yyyy" format in database as well as its populating in msflexgrid in dd/mm/yyyy format. But when try to convert it to excel, in this case only some of the dates formating is changed. Especially the dates from 1-12 is getting interchanged the month and date places. Please help me how to format the cell so that it gets only in dd/mm/yyyy format, or suggest me some ideas to overcome this. Regards,

          A Offline
          A Offline
          Ashfield
          wrote on last edited by
          #4

          I suspect its the cell format in Excel thats causing your problem. If the cell is not defined as a date format then it will display dates in what appears to be an odd format. Try applying a format to your cell and I suspect it will be all OK.

          Bob Ashfield Consultants Ltd

          1 Reply Last reply
          0
          • A aaraaayen

            Hi All, In my vb application, I am generating data from database and retriving it and placing it in MSFlexgrid which includes date column also. And I am using the following code to convert the data from MSFlexgrid to Excel. But in that, in Date column is in properly coming in MSFlexgrid. But when we convert it to Excel, some of the dates (like 12/03/2008, 11/03/2008,04/03,2008..I hope all the dates less than or equal to 12) will be converted like 03/12/2008, 03/04/2008, 03/11/2008...like this. But the other dates 25/03/2008...is populating in Excel correctly. Please help me how to overcome this issue. Dim xlObject As Excel.Application Dim xlWB As Excel.Workbook Set xlObject = New Excel.Application 'This Adds a new woorkbook, you could open the workbook from file also Set xlWB = xlObject.Workbooks.Add Clipboard.Clear 'Clear the Clipboard With MSFlexGrid1 'Select Full Contents (You could also select partial content) .Col = 0 'From first column .Row = 0 'From first Row (header) .ColSel = .Cols - 1 'Select all columns .RowSel = .Rows - 1 'Select all rows Clipboard.SetText .Clip 'Send to Clipboard End With With xlObject.ActiveWorkbook.ActiveSheet .Range("b2").Select 'Select Cell A1 (will paste from here, to different cells) .Paste 'Paste clipboard contents End With ' This makes Excel visible xlObject.Visible = True Thanks in Advance, Regards, R. Sangeetha Priya

            P Offline
            P Offline
            Prakash_Mishra
            wrote on last edited by
            #5

            hey u can do one thing in excel select the column in which u r showing the date, then click on for example A column so that the entire A column gets selected then right click and select format cell then click the tab number then select date then set the format as per ur wish it will set the property for that column permanently. hope it helps

            Prakash Mishra(Banglore,India)

            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