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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Defining cell as date in spreadsheet

Thread ID:

Created:

Updated:

Platform:

Replies:

60933 May 15,2007 07:26 PM UTC May 17,2007 10:32 AM UTC ASP.NET Web Forms (Classic) 3
loading
Tags: XlsIO
Fenella Martinez
Asked On May 15, 2007 07:26 PM UTC

How can I set the cell in the worksheet as a date? Using setValue seems to define it as a string, which makes it hard for sorting in Excel.

Melba Winshia [Syncfusion]
Replied On May 16, 2007 12:11 PM UTC

Hi Fenella,

Thanks for your interest in Essential XlsIO.

You can set the cell in the worksheet as Date by using Value property. Please refer the following code snippet to achieve this:

//Inserting Date into the first worksheet
sheet.Range["A1"].Value = "12/05/2005";
sheet.Range["A2"].Value = "11/05/2005";

Here is the sample for your reference:

http://websamples.syncfusion.com/samples/XlsIO.Windows/F60933/main.htm

Kindly let me know if you have any other questions.

Thanks,
Melba

Anonymous
Replied On May 16, 2007 01:33 PM UTC

also you can use
DateTime value = DateTime.Now

sheet.Range[ "A1" ].DateTime = value;
sheet.Range[ "A2" ].Value2 = value;

or

sheet.Range[ "A1" ].Number = 100;
sheet.Range[ "A1" ].NumberFormat = "mm dd yyyy";// or any other date format

Melba Winshia [Syncfusion]
Replied On May 17, 2007 10:32 AM UTC

Hi,

Yes, you can also use DateTime and Value2 property to set the cell in the worksheet as Date.

Kindly let me know if you have any other questions.

Thanks,
Melba

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.

Warning Icon 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.Close Icon

;