【问题标题】:FileHelpers Tab Delimited Two HeadersFileHelpers 制表符分隔两个标题
【发布时间】:2015-10-12 22:01:34
【问题描述】:

我需要从电子表格制作一个制表符分隔的文本文件:

https://s3.amazonaws.com/seller-templates/ff/na/us/Flat.File.Listingloader.xls

你会看到有两个标题:

我正在使用 C# FileHelper 库。我决定手动创建标题:

                            var engine = new FileHelperEngine<FlatFileListingsData>();

            var orders = new List<FlatFileListingsData>();
            orders.Add(new FlatFileListingsData() { ConditionType = "New", ConditionNote = "New", Price = 9, ProductId = "B009Q76ODU", ProductIdType = "ASIN", Quantity = 1, Sku = "Test1" });

            string rowHeaders = "sku" + "\t" + "price" + "\t" + "quantity" + "\t" + "product-id" + "\t" + "product-id-type" + "\t"  + "condition-type" + "\t" + "condition-note" + "\t" + "ASIN-hint" + "\t" + "title" + "\t" + "product-tax-code" + "\t" + "operation-type" + "\t" + "sale-price" + "\t" + "sale-start-date" + "\t" + "sale-end-date" + "\t" + "leadtime-to-ship" + "\t" + "launch-date" + "\t" + "is-giftwrap-available" + "\t" + "is-gift-message-available" + "\t" + "fulfillment-center-id" + "\t" + "main-offer-image" + "\t" +  "offer-image1" + "\t" + "offer-image2" + "\t" + "offer-image3" + "\t" + "offer-image4" + "\t" + "offer-image5";

            engine.HeaderText = "TemplateType=Offer" + "\t" + "Version=2014.0703" + Environment.NewLine + rowHeaders + Environment.NewLine + rowHeaders;
            engine.WriteFile("output2.txt", orders);



[DelimitedRecord("\t")]
public class FlatFileListingsData
{
    public string Sku { get; set; }
    public decimal Price { get; set; }
    public int Quantity { get; set; }
    public string ProductId { get; set; }
    public string ProductIdType { get; set; }
    public string ConditionType { get; set; }
    public string ConditionNote { get; set; }
}

这是我展示的 xls 文件的准确表示吗?有趣的是,我尝试将此文本文件上传到亚马逊。我收到有关缺少 TemplateType=Offer 行的错误消息:

文件的标题行丢失或无效。标题行仅供亚马逊使用,不得修改或删除。要更正此错误,请从卖家帮助中重新下载模板并使用该新副本,或在现有文件的列标题正上方插入正确的标题行。

【问题讨论】:

标签: c# excel amazon-web-services filehelpers


【解决方案1】:

我相信,使用 FileHelpers,您实际上可以设置所需的标题文本,以便通过插入它们来包含您选择的多行。您甚至可以使用 BeforeWrite 和 AfterWrite 事件(但不要混淆 AfterWrite 实际上是在处理之后但在写入流之前)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-01
    • 2014-01-04
    • 1970-01-01
    • 2012-10-05
    • 1970-01-01
    • 1970-01-01
    • 2018-01-23
    相关资源
    最近更新 更多