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.

Excel export: Formatting column to date type

Thread ID:

Created:

Updated:

Platform:

Replies:

107474 Mar 4,2013 03:45 PM Mar 18,2013 03:33 AM ASP.NET Web Forms (Classic) 3
loading
Tags: XlsIO
Megumi Takahashi
Asked On March 4, 2013 03:45 PM

Hi,
 
I'm trying to format an entire column in an excel file before exporting data to excel.  I'm doing the follwoing but it is not working as I expect.  Am I doing wrong?
 
I want to get the result (Number Type = Custom, formatted date = 'Mon, Mar 18, 2013 00:00') by formatting the entire column.  (strFormat='ddd, mmm dd, yyyy hh:mm')
 
The following code formats the date value correctly, but I have to set the numberformat property for each cell. (The resulting Number Type is Custom 'ddd, mmm dd, yyyy hh:mm', and resulting cell value is 'Mon, Mar 18, 2013 00:00')

objExcelSheet.Range(intRow, intCol).DateTime = dtDateTime

objExcelSheet.Range(intRow, intCol).NumberFormat = strFormat

 

The following code formats the date in a default Date format in excel (The resulting Number Type is Date '*3/14/2001' and resulting cell value is '3/18/2013') 

objExcelSheet.Range(intRow, intCol).DateTime = dtDateTime

objExcelSheet.Columns(intCol).NumberFormat = strFormat

or

objExcelSheet.Columns(intCol).CellStyle.NumberFormat = strFormat

 
Thanks in advance.

Manikandan M [Syncfusion]
Replied On March 7, 2013 11:22 PM

Hi Megumi,

Thanks for using Syncfusion products.

We are afraid that we are not able to reproduce the issue "Applying the specified number format to 'EntireColumn' and any column of worksheet is not working properly" from side in Essential studio version '10.3', '10.4' and '11.1'.We have created the simplified sample to reproduce the issue and have attached the same in the below link. Please make use of this and let us know if this helps you.

Sample link:NumberFormat.zip

If the above sample doesn't meet with sample scenario, please modify the sample reproduce the issue and revert back us with same. It would helps you to analysis the issue and update you the solution. Also please share us the your Essential studio version.

Please let us know if you need any clarifications.

Thanks,
Manikandan M.

Megumi Takahashi
Replied On March 11, 2013 10:20 AM

Hi Manikandan,
 
Thank you for the sample code.  It works fine now after I replaced my code with  'Range.EntireColumn.NumberFormat' as you had in your sample code.  I was not using EntireColumn property.  Thank you very much for your help!

Manikandan M [Syncfusion]
Replied On March 18, 2013 03:33 AM

Hi Megumi,

Thanks for the update.

We are happy to hear that above provided solution is working fine at your side. Please let us know if you need any clarifications.

Thanks,
Manikandan M.

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.

;