Importing Date in a .csv file.
Hello dear support,
I have a problem regarding an import of datatype Date from a .csv file.
The problem is described in the attached screenshit:
- I do import correctly dates in the blue rectangle ( because it can only be a dd/MM/yyyy i suggest), like 13/09/2022. Perfect
- But when the script read the records in the red rectangle, the value from .Value.ToString() switch to MM/dd/yyyy (09/12/2022) instead of beeing (12/09/2022).
I tried various solution, including parsing in code, but also trying to parse the column / cells of the sheet, before actually reading the value. Nothing worked so far.
The sheet cells format for the column in the excel document is of type Date / French.
The above code is just the one I use for creating my record, from the Row object named "ligne". Im using Devexpress.spreaSheet.Workbook library, in order to treat the Excel file. Please see attached a sample of the excel file. Unfortunatly, I can't attach a sample .CSV sample file ... Format unsupported here.
private static void CrerEcritureBancaire(Session session, FichierEcrituresBanque fichier, Row ligne, decimal débit, decimal crédit)
{
EcritureBancaire écritureBancaire = new EcritureBancaire(session);
fichier.EcrituresBancaires.Add(écritureBancaire);
écritureBancaire.Date = DateTime.ParseExact(ligne[0].Value.ToString().Split()[0], "dd/MM/yyyy", CultureInfo.CurrentCulture);
écritureBancaire.Montant = débit == 0 ? crédit : débit;
écritureBancaire.Référence = ligne[1].Value.ToString();
écritureBancaire.Libellé = ligne[2].Value.ToString();
écritureBancaire.Détails = ligne[5].Value.ToString();
}
Could you provide me a solution or a lead to resolve this issue ?
Best regards, Pierre