public static void Save<TSource>(
IEnumerable<TSource> data,
string filePath,
int columnsCount,
CsvMapping mapping,
Action<TSource, Object> conversion,
char delimiter = ',',
Encoding? textEncoding = null
)
Public Shared Sub Save(Of TSource) (
data As IEnumerable(Of TSource),
filePath As String,
columnsCount As Integer,
mapping As CsvMapping,
conversion As Action(Of TSource, Object),
Optional delimiter As Char = ","C,
Optional textEncoding As Encoding = Nothing
)
public:
generic<typename TSource>
static void Save(
IEnumerable<TSource>^ data,
String^ filePath,
int columnsCount,
CsvMapping^ mapping,
Action<TSource, Object^>^ conversion,
wchar_t delimiter = L',',
Encoding^ textEncoding = nullptr
)
static member Save :
data : IEnumerable<'TSource> *
filePath : string *
columnsCount : int *
mapping : CsvMapping *
conversion : Action<'TSource, Object> *
?delimiter : char *
?textEncoding : Encoding
(* Defaults:
let _delimiter = defaultArg delimiter ','
let _textEncoding = defaultArg textEncoding null
*)
-> unit
A method that fills the content of a TSource instance into the properties of mapping.
conversion is called with each CSV row to be written and it gets the TSource instance and mapping as arguments. mapping is passed to the method as dynamic argument: Inside the conversion method the registered DynamicProperty instances can be used like regular .NET properties, but without IntelliSense ("late binding").
With each call of conversion all DynamicProperty instances in mapping are reset to their DefaultValue.
Creates a new CSV file. If the target file already exists, it is truncated and overwritten.
When exchanging CSV data with Excel, the appropriate arguments can be determined with GetExcelArguments.
ArgumentNullException | filePath, or data, or mapping, or conversion is null. |
ArgumentException | filePath is not a valid file path. |
ArgumentOutOfRangeException | columnsCount is negative. |
IOException | I/O error. |