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.

Defining cell as date in spreadsheet

Thread ID:

Created:

Updated:

Platform:

Replies:

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

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 08:11 AM

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 09:33 AM

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 06:32 AM

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.

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.

;