public static void Fill(
DataTable dataTable,
string filePath,
CsvMapping mapping,
char delimiter = ',',
Encoding? textEncoding = null,
bool isHeaderPresent = true,
CsvOpts options = CsvOpts.Default
)
Public Shared Sub Fill (
dataTable As DataTable,
filePath As String,
mapping As CsvMapping,
Optional delimiter As Char = ","C,
Optional textEncoding As Encoding = Nothing,
Optional isHeaderPresent As Boolean = true,
Optional options As CsvOpts = CsvOpts.Default
)
public:
static void Fill(
DataTable^ dataTable,
String^ filePath,
CsvMapping^ mapping,
wchar_t delimiter = L',',
Encoding^ textEncoding = nullptr,
bool isHeaderPresent = true,
CsvOpts options = CsvOpts::Default
)
static member Fill :
dataTable : DataTable *
filePath : string *
mapping : CsvMapping *
?delimiter : char *
?textEncoding : Encoding *
?isHeaderPresent : bool *
?options : CsvOpts
(* Defaults:
let _delimiter = defaultArg delimiter ','
let _textEncoding = defaultArg textEncoding null
let _isHeaderPresent = defaultArg isHeaderPresent true
let _options = defaultArg options CsvOpts.Default
*)
-> unit
Each PropertyName of mapping MUST have a corresponding DataColumn in dataTable - corresponding in the Caption property (case-insensitive) and the accepted data type.
Effort must be taken that the PropertyNames in mapping are unique, even when treated case-insensitive.
The DynamicProperty instances in mapping don't need to match all columns of the DataTable or all columns of the CSV file (neither in number nor in order).
When importing CSV data from Excel, the appropriate arguments can be determined with GetExcelArguments.
ArgumentNullException | dataTable, or filePath, or mapping is null. |
ArgumentException | filePath is not a valid file path. - or - There is a DynamicProperty in mapping whose PropertyName finds no corresponding ColumnName in dataTable. |
FormatException | Parsing fails and Throwing is true. |
NoNullAllowedException | The mapping doesn't match the schema of the dataTable. |
ConstraintException | The parsed CSV data does not match the schema of the dataTable. |
IOException | I/O error. |
ObjectDisposedException | The file was already closed. |