We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert from Text to Date using Aspose.Cells for .NET in C#

Hi. I have a data in excel file like this,
…Date… | Aging Date |
18-01-2019| |

This “Date” column in in format text and in column(1).
My question is, what should I to do make it like this,
18-jan-2019 |
18-jan-2019 |
18-jan-2019 |
18-jan-2019 |
18-jan-2019 |


Thanks for your query.

See the sample code segment for your reference:
Sample code:

			//Get the first worksheet in the workbook.
			Worksheet worksheet = workbook.Worksheets[0]; 
			//Define a style object adding a new style 
			//to the collection list. 
			Style stl = workbook.CreateStyle();;
			//Set the integer format.
			stl.Custom = "dd-mmm-yyyy";
			//Set the style flag struct.
			StyleFlag flag = new StyleFlag();
			//Apply the number format.
			flag.NumberFormat = true;
			//Get the first column (A) in the worksheet.
			Column col1 = worksheet.Cells.Columns[0];
			//Apply the style to it.

Please note, the custom formatting would only work if your data is in DateTime, so if it is in simple text format, you got to convert it to DateTime format first.

Hope, this helps a bit.