Using SuperCSV to Change Header Values

前端 未结 1 1804
栀梦
栀梦 2021-02-10 05:02

In line with this post about abilities of SuperCSV, can SuperCSV handle changing the values of the headers(column names only) read from the database?

相关标签:
1条回答
  • 2021-02-10 05:34

    I'm not sure if this answers your question, but you can put whatever you like in the header - it doesn't have to be identical to the mapping array passed to beanWriter.write()

    For example, the following will give the output you desire:

    final String[] header = new String[] { "First Name", "Last Name", "Birthday"};
    final String[] fieldMapping = new String[] { "firstName", "lastName", "birthDate"};
    
    // write the header
    beanWriter.writeHeader(header);
    
    // write the beans
    for( final CustomerBean customer : customers ) {
       beanWriter.write(customer, fieldMapping , processors);
    }
    
    0 讨论(0)
提交回复
热议问题