Date Formating getting changed when Converting MSFlexgrid content to Excel
-
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
-
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
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)
-
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)
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,
-
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,
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
-
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
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)