I am initializing some cells with a customized date value, converted as a string, such as dd/mm/yyyy. This is received as a string to Excel. When I sort the column, it sorts it as a string and not as a column date recognized.
How can I achieve this column date recognition but still preserving my string cell initialization as I need to pass various date formats and if I initialize the cell directly with the data, I will not be able to obtain that.
This is because, based on the user, the report is generated in a certain way. So, they have different date format. Also, some columns are shown as dd/mm/yyyy, some others as dd/mm/yyyy hh:mm, some others as dd/mm/yyyy hh:mm:ss. Other variations could be mm/dd/yyyy, mm/dd/yyyy hh:mm, even yyyy just to show the year or mmyyyy just to show the month and year without special characters and so on.
So, yes, I do have to pass this as a string. Should I simply tell the client that there is no way to have it both ways?
I still don't see the reason you can't enter this as a date, and then dynamically format the cell as mm/dd/yyyy, mm/dd/yyyy hh:mm, dd/mm/yyyy, etc. Everythig you are doing can be done by dynamically formatting the cells. You can even have a special mode (formats marked with *) which will change depending on the locale, if you want that. So an english user would see "mm/dd/yyyy" and an spanish user "dd/mm/yyyy" when opening the same file.
We cannot use the local settings. This is dependent on the Web site user account setting.
I am using XlsFile in .NET.
It is good to know there is a way. I will wait for your input.
Ok, I found what was causing this effect in my code. The support was already there but it as skipping it.