Search code examples
c#.netcsvfilehelpers

Filehelpers some columns are not written


I am writing this class to a file. But for some reason, some of the rows have some columns missing.

By this, I mean that some columns are shifted a few times to the left. I can see this on the last column, because it should have a "true" in all rows, and they have been moved 1 or 2 times to the left.

This happens even though all of the Vare have the correct values, so it is while writing it happens.

Any ideas on why this happens.

[DelimitedRecord("\t")]
    internal class Vare : IBusinessCentral<AxVare>
    {
        public Vare()
        {
        }

        public string Nummer { get; set; }
        public string Nummer2 { get; set; }
        public string Beskrivelse { get; set; }
        public string Søgebeskrivelse { get; set; }
        public string Beskrivelse2{ get; set; }
        public string Basisenhed { get; set; }
        public string Type { get; set; }
        public string Varebogføringsgruppe { get; set; }
        public string Varerabatgruppe { get; set; }
        public string Enhedspris { get; set; }
        public string AvancepctBeregning { get; set; }
        public string Kostprisberegningsmetode { get; set; }
        public string Kostpris { get; set; }
        public string SidsteKøbspris { get; set; }
        public string Genbestillingspunkt { get; set; }
        public string Ordrekvantum { get; set; }
        public string Bruttovægt { get; set; }
        public string Nettovægt { get; set; }
        public string Varekode { get; set; }
        public string MomsvirksBogfGruppePris { get; set; }
        public string Produktbogføringsgruppe { get; set; }
        public string AutomatiskUdvTekster { get; set; }
        public string MomsproduktbogfGruppe { get; set; }
        public string Reserver { get; set; }
        public string GlobalDimension2kode { get; set; }
        public string Beholdningsadvarsel { get; set; }
        public string ForebygNegativtLager { get; set; }
        public string Genbestillingssystem { get; set; }
        public string Salgsenhed { get; set; }
        public string Købsenhed { get; set; }
        public string Genbestillingsmetode { get; set; }
        public string MedtagLager { get; set; }
        public string Producentkode { get; set; }
        public string Varekategorikode { get; set; }
        public string Indkøbskode { get; set; }
        public string Varesporingskode { get; set; }
        public string Udløbsberegning { get; set; }
        public string LægPåLagerSkabelonkode { get; set; }
        public string LægPåLagerEnhedskode { get; set; }
        public string KodeForOvermodtagelse { get; set; }
        public string System { get; set; }
        public string FarligtGods { get; set; }
        public string Model { get; set; }
        public string Note { get; set; }
        public string Variantstyrret { get; set; }
        public string UndladPrint { get; set; }
    }

The function writing to disk

        private static void Write<T>(string path, T[] output) where T : class
        {
            var outputEngine = new FileHelperEngine<T>();
            outputEngine.HeaderText = outputEngine.GetFileHeader();
            outputEngine.WriteFile(path, output);
        }

Solution

  • So after a few hours of debugging I found out that it is not Filehelpers which is the problem, but Excel that does not read the tabs correctly.