Replies: 1 comment 2 replies
-
What type is your value? If it's a number type, you can specify a formatter in your mapping. void Main()
{
var records = new List<Foo>
{
new Foo { Id = 1, Name = "one" },
};
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
};
using (var writer = new StringWriter())
using (var csv = new CsvWriter(writer, config))
{
csv.Context.RegisterClassMap<FooMap>();
csv.WriteRecords(records);
writer.Dump();
}
}
private class Foo
{
public int Id { get; set; }
public string Name { get; set; }
}
private class FooMap : ClassMap<Foo>
{
public FooMap()
{
Map(m => m.Id).TypeConverterOption.Format("000");
Map(m => m.Name);
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My Value Is 004,After Export To CSV File Change Number To 4, Delete Automatically Zero Before My Value How To Keep Zero Before Number?
Beta Was this translation helpful? Give feedback.
All reactions