Qin.CsvRelevant
2.0.0
dotnet add package Qin.CsvRelevant --version 2.0.0
NuGet\Install-Package Qin.CsvRelevant -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Qin.CsvRelevant" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Qin.CsvRelevant" Version="2.0.0" />
<PackageReference Include="Qin.CsvRelevant" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Qin.CsvRelevant --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Qin.CsvRelevant, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Qin.CsvRelevant@2.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Qin.CsvRelevant&version=2.0.0
#tool nuget:?package=Qin.CsvRelevant&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Qin.CsvRelevant
Csv Export Install
Install-Package Qin.CsvRelevant -Version 2.0.0
public void ConfigureServices(IServiceCollection services)
{
services.AddCsvGenerate();
}
1.Customize CSV file header
List<dynamic> listData = new List<dynamic>();
listData.Add(new { name = "Sully1", Poe = 12333 });
listData.Add(new { name = "Ben1", Poe = 12333 });
listData.Add(new { name = "Fiy1", Poe = 12333 });
Dictionary<string, string> column = new Dictionary<string, string>();
column.Add("MyName", "name");
column.Add("MyOrderId", "Poe");
var charBytes = await _csvGenerate.WriteAsync(listData, column, "xxx\\demo1.csv");
2.Specify the mapping relationship through fluent
List<ExportEntity> listData2 = GetList();
var culumn2 = _csvGenerate.Map<ExportEntity>("MyOrderId", a => a.Orderid)
.Map<ExportEntity>("MyName", a => a.Name)
.Map<ExportEntity>("MyName2", a => a.Name2)
.Map<ExportEntity>("MyName3", a => a.Name3)
.Map<ExportEntity>("State", a => a.State)
.Map<ExportEntity>("Money", a => a.Money)
.Map<ExportEntity>("Isdel", a => a.Isdel)
.Map<ExportEntity>("Area", a => a.Area).BuildDictionary();
_csvGenerate.ForMat = (column, fieldname, fieldvalue) =>
{
if (fieldvalue is null)
return fieldvalue;
// The default value of the time field is "yyyy MM DD HH: mm: SS"
/*if (column == "Date" && fieldname == "CreateTime")
{
fieldvalue = fieldvalue is DateTime s1 ? s1.ToString("yyyy-MM-dd") : fieldvalue;
}*/
return fieldvalue;
};
var charBytes2 = await _csvGenerate.WriteAsync(listData2, culumn2, "xxx\\demo2.csv");
3.Entity tag mapping column name
public class ExportEntity
{
[Qin.CsvRelevant.ExportColumn("Myorderid")]
public int Orderid { get; set; }
[Qin.CsvRelevant.ExportColumn("myname")]
public string Name { get; set; }
[Qin.CsvRelevant.ExportColumn("Date")]
public DateTime CreateTime { get; set; }
}
// Split line
List<ExportEntity> listData = new List<ExportEntity>();
listData.Add(new ExportEntity { Name = "Sully", Orderid = 12333 });
listData.Add(new ExportEntity { Name = "Ben", Orderid = 12333 });
listData.Add(new ExportEntity { Name = "Fiy", Orderid = 12333 });
var charBytes0 = await _csvGenerate.WriteByAttributeAsync(listData, "xxx\\demo3.csv");
When writing a CSV file, when the "file name" field is null or the default value, byte [] will be returned, but the file will not be generated
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Dapper (>= 2.1.24)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 372 | 12/17/2023 |
| 1.1.1.4 | 557 | 7/31/2023 |
| 1.1.1.3-alpha | 257 | 3/5/2023 |
| 1.1.1.2 | 2,089 | 5/9/2022 |
| 1.1.1.1-alpha | 1,619 | 3/31/2022 |
| 1.0.4.2 | 531 | 3/31/2022 |
| 1.0.4.1-alpha | 365 | 3/16/2022 |
| 1.0.4 | 556 | 3/15/2022 |
| 1.0.3.4 | 555 | 3/14/2022 |
| 1.0.3.3 | 566 | 3/14/2022 |
| 1.0.3.2 | 557 | 3/14/2022 |
| 1.0.3.1 | 564 | 3/8/2022 |
| 1.0.3 | 567 | 3/4/2022 |
| 1.0.2 | 536 | 3/4/2022 |
| 1.0.1 | 572 | 3/1/2022 |
| 1.0.0 | 545 | 3/1/2022 |
加入Dapper,大量数据导出优化