/// <summary> /// Renders the value of the column. /// </summary> /// <param name="defintion"> The CSV definition. </param> /// <param name="value"> The value to render. </param> /// <param name="culture"> the culture to render in. </param> /// <param name="formatter"> The formatter to use for rendering the value into the cell. </param> /// <returns>A string that can be directly written into the CSV file. </returns> protected override string OnRender(ICsvDefinition defintion, IEnumerable <TArray> value, CultureInfo culture, IStringFormatter formatter) { var values = value.Select(e => CleanAndFormatValue(defintion, e)).ToArray(); var element = string.Join(this.ElementDelimiter, values); return(formatter.FormatStringCell(element, defintion.RemoveNewLineCharacters)); }
protected virtual string OnRender(ICsvDefinition defintion, TResult value, CultureInfo formattingCulture, IStringFormatter formatter) { if (value == null) { return(string.Empty); } return(value.ToString()); }
/// <summary> /// Executed each time the cell/value is written to a file. /// </summary> /// <param name="defintion"> The CSV definition. </param> /// <param name="value"> The value to render. </param> /// <param name="culture"> the culture to render in. </param> /// <param name="formatter"> The formatter to use for rendering the value into the cell. </param> /// <returns>A string that can be directly written into the CSV file. </returns> public override string[] Render(ICsvDefinition defintion, TSource value, CultureInfo culture, IStringFormatter formatter) { var collection = this.Selector(value); return((from item in collection let column = converter(item) select column.Render(defintion, item, culture, formatter)) .SelectMany(elements => elements) .ToArray()); }
protected override string OnRender(ICsvDefinition defintion, string value, CultureInfo culture, IStringFormatter formatter) { var text = this.Format(value ?? string.Empty, culture); if (this.ForceNumberToTextFormatting) { return(formatter.FormatForcedExcelStringCell(text, defintion.RemoveNewLineCharacters)); } return(formatter.FormatStringCell(text, defintion.RemoveNewLineCharacters)); }
/// <summary> /// Initializes a new instance of the <see cref="CsvStreamLineReader"/> class. /// </summary> /// <param name="definition">The CSV definition.</param> /// <param name="headers">The header names.</param> public CsvStreamLineReader(ICsvDefinition definition, HeaderCollection headers) { this.headers = headers; this.definition = definition; }
/// <summary> /// Initializes a new instance of the <see cref="CsvStreamLineReader"/> class. /// </summary> /// <param name="definition">The CSV definition.</param> /// <param name="headers">The header names.</param> public CsvStreamLineReader(ICsvDefinition definition, params string[] headers) : this(definition, new HeaderCollection(headers)) { }
/// <summary> /// Initializes a new instance of the <see cref="CsvStreamLineReader"/> class. /// </summary> public CsvStreamLineReader(ICsvDefinition definition) : this(definition, new string[] { }) { }
/// <summary>Executed each time the cell/value is written to a file.</summary> /// <param name="defintion">The CSV definition.</param> /// <param name="value">The value to render.</param> /// <param name="culture">the culture to render in.</param> /// <param name="formatter">The formatter to use for rendering the value into the cell.</param> /// <returns>A string that can be directly written into the CSV file.</returns> protected override string OnRender(ICsvDefinition defintion, int?value, CultureInfo culture, IStringFormatter formatter) { return(this.Format(value, culture)); }
/// <summary> /// Renders the specified element contents. /// </summary> /// <param name="element">The element.</param> /// <returns></returns> public virtual string[] Render(ICsvDefinition definition, TSource element, CultureInfo formattingCulture, IStringFormatter formatter) { var value = this.Selector(element); return(new[] { this.OnRender(definition, value, formattingCulture.Parent, formatter) }); }
/// <summary> /// Renders the specified element. /// </summary> /// <param name="element">The element.</param> /// <returns></returns> public override string[] Render(ICsvDefinition defintion, TSource element, CultureInfo culture, IStringFormatter formatter) { var collection = this.Selector(element); return(this.ProcessElementsByHeaderNames(collection, culture, formatter).ToArray()); }
private string CleanAndFormatValue(ICsvDefinition defintion, TArray e) { return(this.Format(e).Replace(this.ElementDelimiter, "_")); }