Setting one column datatype to datetime

I am trying to set 39th column to a datetime datatype.
Please help

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please use the Column.ApplyStyle() method for your needs.

Please see the complete sample code how to set the 39th column to date type. I have also attached the output file generated by this code for your reference.

Please also see the screenshot for more help.

C#


Workbook workbook = new Workbook();


Worksheet worksheet = workbook.Worksheets[0];


Style style = workbook.CreateStyle();

style.Number = 14; //For date


StyleFlag sf = new StyleFlag();

sf.All = true;


Column col = worksheet.Cells.Columns[38];//since it is 0 based so 38 means 39th column


col.ApplyStyle(style, sf);


workbook.Save(“output.xlsx”);

Screenshot:

Thank you very much for the detailed explanation.

I have an Excel consisting of 45 columns withing it, i already applied a different back color from 39th to 44th column. now i need to change the datatype as 39 & 40 to datetime and 41 to number and the rest to text datatype.
Please help.

Hi,

Thanks for your feedback.

For applying datetime to columns 39th and 44th, please use the same code as given above.

To apply number type to column 41, please use the same code as given above except that you will set Style.Number = 2

To apply rest of the columns to text, please use the same code as given above except that you will set Style.Number = 49

For your more help, please refer to this article.