Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add my report list columns' name as a header to the csv file when the HasHeaderRecord is set to false #2245

Open
ElhamJedi opened this issue Apr 7, 2024 · 0 comments
Labels

Comments

@ElhamJedi
Copy link

ElhamJedi commented Apr 7, 2024

I want to write a report list of objects to csv without header so set the HasHeaderRecord to false.
but it's still adding columns' name as a header row.

`using (var writer = new StringWriter())
using (var csv = GetCsvWriter(writer, false))
{
csv.Context.RegisterClassMap();

                var data = mapper.Map<List<ExportContactTracingReportModel>>(report) :
                csv.WriteRecords(data);
        }



    public static CsvWriter GetCsvWriter(StringWriter writer, bool hasHeaderRecord = true)
        => new CsvWriter(writer,
            new CsvConfiguration(CultureInfo.InvariantCulture)
            {
                InjectionOptions = InjectionOptions.Strip,
                HasHeaderRecord = hasHeaderRecord,
            });`
@ElhamJedi ElhamJedi added the bug label Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant