anmcgrath / BlazorDatasheet

Simple excel-like datasheet Blazor component
MIT License
163 stars 40 forks source link

Values changes to DateTime in different CultureInfo ! #88

Open piramouns opened 3 months ago

piramouns commented 3 months ago

Hi, at first I thank you for this nice component, I appriciate you for sharing it, When we use a different CultureInfo for example persian ( fa-IR ) , after entring a float value in a cell for example 3.5 , component changes it to 1403/3/5 0:00:00 that's a date in persian calendar, How I can fix it?

My regards

anmcgrath commented 3 months ago

Hi @piramouns does the cell have a type set to DateTime? I'm a bit confused as to why this would happen. Can you share an example?

The only thing is it might be parsing the number as a DateTime? This is handled in CellValue.cs

piramouns commented 3 months ago

Hi, Thanks for your reply, you can check it via this sample page , https://colifeqm.com/analysis/ge ( the CultureInfo is fa-IR ) I have set cell type as number but it not works, after loading just enter value 3.5 in a cell,

anmcgrath commented 3 months ago

Hey, thanks for the example. I was able to reproduce it in your example and on my machine when setting the CultureInfo to fa-IR.

The sheet is trying to figure out the datatype from the string that you enter ("3.5"), it first tries to parse as a number and then tries to parse the date. I don't know anything about the fa-IR culture info, except that I can see that the culture info NumberFormat.NumberDecimalSeperator is set to "٫". If you change it to "." then it'll parse numbers as you mentioned you wanted to.

piramouns commented 3 months ago

Hi, I really appreciate your effort to find the issue, I try it and back to you , hopefully it works for me too, 👍