2016-11-10 7 views
0

私の見出しを引用するようにしてきましたが、残念ながら私はどのように理解できません。 [FieldQuoted('"', QuoteMode.AlwaysQuoted, MultilineMode.NotAllow)] FileHelpersで引用符で囲まれたヘッダー

はデータだけではなく、ヘッダーのために働く、と私は可能性が:

  UserSubEngine.HeaderText = '"WHATEVER,WHATEVER,WHATEVER"'; 

私は1つのラインで23の異なるヘッダを書きたくはありません。

私はむしろ使用します。

  UserSubEngine.HeaderText = UserSubEngine.GetFileHeader(); 

可能なすべての場合。

提案がありますか?

答えて

0

HeaderTextです。 FieldQuotedは、GetFileHeader()の出力には影響しません。

ここにsource codeの関連部分です。

/// <summary> 
/// Builds a line with the name of the fields, for a delimited files it 
/// uses the same delimiter, for a fixed length field it writes the 
/// fields names separated with tabs 
/// </summary> 
/// <returns>field names structured for the heading of the file</returns> 
public string GetFileHeader() 
{ 
    var delimiter = "\t"; 

    if (RecordInfo.IsDelimited) 
     delimiter = ((DelimitedRecordOptions) Options).Delimiter; 

    var res = new StringBuilder(); 
    for (int i = 0; i < RecordInfo.Fields.Length; i++) { 
     if (i > 0) 
      res.Append(delimiter); 

     var field = RecordInfo.Fields[i]; 
     res.Append(field.FieldCaption != null 
      ? field.FieldCaption 
      : field.FieldFriendlyName); 
    } 

    return res.ToString(); 
} 
+0

HeaderTextは私が使いたいものではありません。それはあまりにも頑丈で、ひどくプログラムされているので、より良い解決策が必要です。 –

+0

あります。あなたが[ここ](https://github.com/MarcosMeli/FileHelpers)に貢献する素晴らしい機会です。上の 'GetFileHeader()'を修正し、プルリクエストを送信してください。 – shamp00

関連する問題