Class CsvHelper
CsvHelper
public static class CsvHelper
- Inheritance
-
CsvHelper
- Inherited Members
Fields
CsvQuoteCharacter
CsvQuoteCharacter, "
by default
public static char CsvQuoteCharacter
Field Value
CsvSeparatorCharacter
CsvSeparatorCharacter, ',' by default
public static char CsvSeparatorCharacter
Field Value
Methods
GetCsvLines<TEntity>(IEnumerable<TEntity>, CsvOptions?)
Get csv lines
public static IEnumerable<string> GetCsvLines<TEntity>(this IEnumerable<TEntity> entities, CsvOptions? csvOptions = null)
Parameters
entities
IEnumerable<TEntity>entities
csvOptions
CsvOptionscsvOptions
Returns
- IEnumerable<string>
csv lines
Type Parameters
TEntity
entity type
GetCsvText(DataTable?, bool)
Get csv text
public static string GetCsvText(this DataTable? dataTable, bool includeHeader = true)
Parameters
Returns
GetCsvText(DataTable?, CsvOptions)
GetCsvText
public static string GetCsvText(this DataTable? dataTable, CsvOptions csvOptions)
Parameters
dataTable
DataTabledataTable
csvOptions
CsvOptionscsvOptions
Returns
- string
csv text
GetCsvText<TEntity>(IEnumerable<TEntity>, bool)
Get csv text
public static string GetCsvText<TEntity>(this IEnumerable<TEntity> entities, bool includeHeader = true)
Parameters
entities
IEnumerable<TEntity>includeHeader
bool
Returns
Type Parameters
TEntity
GetCsvText<TEntity>(IEnumerable<TEntity>, CsvOptions)
Get csv text
public static string GetCsvText<TEntity>(this IEnumerable<TEntity> entities, CsvOptions csvOptions)
Parameters
entities
IEnumerable<TEntity>csvOptions
CsvOptions
Returns
Type Parameters
TEntity
GetEntities<TEntity>(IEnumerable<string>, CsvOptions?)
public static IEnumerable<TEntity?> GetEntities<TEntity>(IEnumerable<string> csvLines, CsvOptions? csvOptions = null)
Parameters
csvLines
IEnumerable<string>csvOptions
CsvOptions
Returns
- IEnumerable<TEntity>
Type Parameters
TEntity
GetEntities<TEntity>(string, CsvOptions?)
public static IEnumerable<TEntity?> GetEntities<TEntity>(string csvText, CsvOptions? csvOptions = null)
Parameters
csvText
stringcsvOptions
CsvOptions
Returns
- IEnumerable<TEntity>
Type Parameters
TEntity
GetEntityList<TEntity>(IEnumerable<string>, CsvOptions?)
public static List<TEntity?> GetEntityList<TEntity>(IEnumerable<string> csvLines, CsvOptions? csvOptions = null)
Parameters
csvLines
IEnumerable<string>csvOptions
CsvOptions
Returns
- List<TEntity>
Type Parameters
TEntity
GetEntityList<TEntity>(string, CsvOptions?)
public static List<TEntity?> GetEntityList<TEntity>(string csvText, CsvOptions? csvOptions = null)
Parameters
csvText
stringcsvOptions
CsvOptions
Returns
- List<TEntity>
Type Parameters
TEntity
ParseLine(string)
public static IReadOnlyList<string> ParseLine(string line)
Parameters
line
string
Returns
ParseLine(string, CsvOptions)
public static IReadOnlyList<string> ParseLine(string line, CsvOptions csvOptions)
Parameters
line
stringcsvOptions
CsvOptions
Returns
ToCsvBytes(DataTable)
to csv bytes
public static byte[] ToCsvBytes(this DataTable dt)
Parameters
dt
DataTable
Returns
- byte[]
ToCsvBytes(DataTable, bool)
to csv bytes
public static byte[] ToCsvBytes(this DataTable dataTable, bool includeHeader)
Parameters
Returns
- byte[]
ToCsvBytes(DataTable, CsvOptions)
to csv bytes
public static byte[] ToCsvBytes(this DataTable dataTable, CsvOptions csvOptions)
Parameters
dataTable
DataTablecsvOptions
CsvOptions
Returns
- byte[]
ToCsvBytes<TEntity>(IEnumerable<TEntity>)
to csv bytes
public static byte[] ToCsvBytes<TEntity>(this IEnumerable<TEntity> entities)
Parameters
entities
IEnumerable<TEntity>
Returns
- byte[]
Type Parameters
TEntity
ToCsvBytes<TEntity>(IEnumerable<TEntity>, bool)
to csv bytes
public static byte[] ToCsvBytes<TEntity>(this IEnumerable<TEntity> entities, bool includeHeader)
Parameters
entities
IEnumerable<TEntity>includeHeader
bool
Returns
- byte[]
Type Parameters
TEntity
ToCsvBytes<TEntity>(IEnumerable<TEntity>, CsvOptions)
to csv bytes
public static byte[] ToCsvBytes<TEntity>(this IEnumerable<TEntity> entities, CsvOptions csvOptions)
Parameters
entities
IEnumerable<TEntity>csvOptions
CsvOptions
Returns
- byte[]
Type Parameters
TEntity
ToCsvFile(DataTable, string)
save to csv file
public static bool ToCsvFile(this DataTable dt, string filePath)
Parameters
Returns
ToCsvFile(DataTable, string, bool)
save to csv file
public static bool ToCsvFile(this DataTable dataTable, string filePath, bool includeHeader)
Parameters
Returns
ToCsvFile(DataTable, string, CsvOptions)
save to csv file
public static bool ToCsvFile(this DataTable dataTable, string filePath, CsvOptions csvOptions)
Parameters
dataTable
DataTablefilePath
stringcsvOptions
CsvOptions
Returns
ToCsvFileAsync<TEntity>(IEnumerable<TEntity>, string, CsvOptions?)
public static Task<bool> ToCsvFileAsync<TEntity>(this IEnumerable<TEntity> entities, string filePath, CsvOptions? csvOptions = null)
Parameters
entities
IEnumerable<TEntity>filePath
stringcsvOptions
CsvOptions
Returns
Type Parameters
TEntity
ToCsvFile<TEntity>(IEnumerable<TEntity>, string)
save to csv file
public static bool ToCsvFile<TEntity>(this IEnumerable<TEntity> entities, string filePath)
Parameters
entities
IEnumerable<TEntity>filePath
string
Returns
Type Parameters
TEntity
ToCsvFile<TEntity>(IEnumerable<TEntity>, string, bool)
save to csv file
public static bool ToCsvFile<TEntity>(this IEnumerable<TEntity> entities, string filePath, bool includeHeader)
Parameters
entities
IEnumerable<TEntity>filePath
stringincludeHeader
bool
Returns
Type Parameters
TEntity
ToCsvFile<TEntity>(IEnumerable<TEntity>, string, CsvOptions)
public static bool ToCsvFile<TEntity>(this IEnumerable<TEntity> entities, string filePath, CsvOptions csvOptions)
Parameters
entities
IEnumerable<TEntity>filePath
stringcsvOptions
CsvOptions
Returns
Type Parameters
TEntity
ToDataTable(byte[])
convert csv file data to dataTable
public static DataTable ToDataTable(byte[] csvBytes)
Parameters
csvBytes
byte[]csv bytes
Returns
ToDataTable(byte[], CsvOptions)
public static DataTable ToDataTable(byte[] csvBytes, CsvOptions csvOptions)
Parameters
csvBytes
byte[]csvOptions
CsvOptions
Returns
ToDataTable(Stream)
convert csv stream data to dataTable
public static DataTable ToDataTable(Stream stream)
Parameters
stream
Streamstream
Returns
ToDataTable(Stream, CsvOptions)
convert csv stream data to dataTable
public static DataTable ToDataTable(Stream stream, CsvOptions csvOptions)
Parameters
stream
Streamstream
csvOptions
CsvOptionscsvOptions
Returns
ToDataTable(string)
convert csv file data to dataTable
public static DataTable ToDataTable(string filePath)
Parameters
filePath
stringcsv file path
Returns
ToEntities<TEntity>(byte[], CsvOptions?)
public static IEnumerable<TEntity?> ToEntities<TEntity>(byte[] csvBytes, CsvOptions? csvOptions = null)
Parameters
csvBytes
byte[]csvOptions
CsvOptions
Returns
- IEnumerable<TEntity>
Type Parameters
TEntity
ToEntities<TEntity>(Stream, CsvOptions?)
public static IEnumerable<TEntity?> ToEntities<TEntity>(Stream csvStream, CsvOptions? csvOptions = null)
Parameters
csvStream
StreamcsvOptions
CsvOptions
Returns
- IEnumerable<TEntity>
Type Parameters
TEntity
ToEntities<TEntity>(string, CsvOptions?)
convert csv file data to entities
public static IEnumerable<TEntity?> ToEntities<TEntity>(string filePath, CsvOptions? csvOptions = null)
Parameters
filePath
stringcsv file path
csvOptions
CsvOptionscsvOptions
Returns
- IEnumerable<TEntity>
Type Parameters
TEntity
ToEntityList<TEntity>(byte[])
convert csv byte data to entity list
public static List<TEntity?> ToEntityList<TEntity>(byte[] csvBytes)
Parameters
csvBytes
byte[]csv bytes
Returns
- List<TEntity>
Type Parameters
TEntity
ToEntityList<TEntity>(byte[], CsvOptions)
convert csv byte data to entity list
public static List<TEntity?> ToEntityList<TEntity>(byte[] csvBytes, CsvOptions csvOptions)
Parameters
csvBytes
byte[]csv bytes
csvOptions
CsvOptionscsvOptions
Returns
- List<TEntity>
Type Parameters
TEntity
ToEntityList<TEntity>(Stream)
convert csv stream data to entity list
public static List<TEntity?> ToEntityList<TEntity>(Stream csvStream)
Parameters
csvStream
Streamcsv Stream
Returns
- List<TEntity>
Type Parameters
TEntity
ToEntityList<TEntity>(Stream, CsvOptions)
public static List<TEntity?> ToEntityList<TEntity>(Stream csvStream, CsvOptions csvOptions)
Parameters
csvStream
StreamcsvOptions
CsvOptions
Returns
- List<TEntity>
Type Parameters
TEntity
ToEntityList<TEntity>(string)
convert csv file data to entity list
public static List<TEntity?> ToEntityList<TEntity>(string filePath)
Parameters
filePath
stringcsv file path
Returns
- List<TEntity>
Type Parameters
TEntity
ToEntityList<TEntity>(string, CsvOptions)
convert csv file data to entity list
public static List<TEntity?> ToEntityList<TEntity>(string filePath, CsvOptions csvOptions)
Parameters
filePath
stringcsv file path
csvOptions
CsvOptionscsvOptions
Returns
- List<TEntity>
Type Parameters
TEntity