We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to set date format

Thread ID:

Created:

Updated:

Platform:

Replies:

123844 Apr 26,2016 08:28 AM Apr 27,2016 09:47 AM ASP.NET Web Forms 1
loading
Tags: XlsIO
gaurav singh
Asked On April 26, 2016 08:28 AM

I want to set date format "mm-dd-yy" to excel entire column of IWorksheet, and date fileld containing value like "01/30/16". After writing excel file i open file and checked date field there is no formatting applied. Same issue with number field.Following is code please have a look and help me out.

         Dim cIndex As Integer = 0
                Dim rIndex As Integer = 0

                For Each dc In dtExport.Columns
                    cIndex = cIndex + 1
                    sheet.Range(1, cIndex).Text = dc.ColumnName
                Next
                For Each dr In dtExport.Rows
                    rIndex = rIndex + 1
                    cIndex = 0
                    For Each dc In dtExport.Columns
                        cIndex = cIndex + 1
                        sheet.Range(rIndex + 1, cIndex).Text = dr(dc.ColumnName).ToString()
                    Next
                Next

                For Each column In formattedColumns
                    For Each sheetColumn As IRange In sheet.Columns
                        If sheetColumn.DisplayText = column.Name Then
                            If column.DataType.ToLower() = "datetime" Then
                                sheetColumn.CellStyle.NumberFormat = "mm/dd/yy"
                                sheetColumn.DateTime = Date.Parse(DateTime.Now)
                            ElseIf column.DataType.ToLower() = "currency" Then
                                sheet.Range().NumberFormat = DataHelper.GetSafeStr(column.DataFormat)
                            End If
                            Exit For
                        End If

                    Next

                Next




Abirami Varadharajan [Syncfusion]
Replied On April 27, 2016 09:47 AM

Hi Gaurav, 
 
Thank you for contacting Syncfusion support. 
 
We are unable to reproduce the reported issue from our side. We have prepared the sample based on the given code example and shared it for your reference which can be downloaded from the following link. 
 
 
Kindly share us the issue reproducing file or modified sample to reproduce the issue, which will be helpful for us to provide you a prompt solution at the earliest. 
 
Regards, 
Abirami. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;