简体   繁体   English

Filehelpers 有些列没有写

[英]Filehelpers some columns are not written

I am writing this class to a file.我正在将此 class 写入文件。 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.我可以在最后一列看到这一点,因为它在所有行中都应该有一个“真”,并且它们已经向左移动了 1 或 2 次。

This happens even though all of the Vare have the correct values, so it is while writing it happens.即使所有的Vare都有正确的值,也会发生这种情况,所以它是在编写时发生的。

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 function 写入磁盘

        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);
        }

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.所以经过几个小时的调试后,我发现问题不是 Filehelpers,而是 Excel 没有正确读取选项卡。

Excel has an option that you can tick/untick says something like "Treat multiple consecutive delimiters as one", I would suspect that you have that set. Excel 有一个选项,您可以勾选/取消勾选类似“将多个连续分隔符视为一个”之类的选项,我怀疑您有该设置。

As stated in the "Must Read" section of the official site:正如官方网站的“必读”部分所述:

The current implemented Excel support is only for basic scenarios.当前实现的 Excel 支持仅适用于基本场景。 If you need custom formatting, charts, etc. you must go for a custom code.如果您需要自定义格式、图表等,您必须为自定义代码 go。 It's strongly recommended to directly use the NPOI library强烈建议直接使用 NPOI 库

To be honest I like FileHelpers for CSV... but I wouldn't bother for Excel.老实说,我喜欢 CSV 的 FileHelpers ......但我不会为 Excel 烦恼。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM