How to get the exact name in @CsvBindByName?

Udi :

When using OpenCSV in order to write csv i'm using the CSVBindByName annotation this way:

    @CsvBindByName(column = "Date")
    private Long date;
    @CsvBindByName(column = "Post content")
    private String text;

But in the generated file the headers are all in UPPERCASE: DATE, POST CONTENT

Is there any way to generate the exact name in the annotation?

piy26 :

Seems that the CsvBindByName annotation always converts the column name to UpperCase based on the OpenCSV source code @ https://sourceforge.net/p/opencsv/source/ci/master/tree/src/main/java/com/opencsv/bean/HeaderColumnNameMappingStrategy.java#l210

You can try to use custom converter as detailed out here:

OpenCsv writes wrong column names with BeanToCsv + HeaderColumnNameTranslateMappingStrategy

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=160302&siteId=1