0

I'm writing using StatefulBeanToCsvBulder. The file format requires that the header have file meta-data, rather than columns. There are 3 bean types.

StatefulBeanToCsv headerCsvBuilder = new StatefulBeanToCsvBuilder(writer)
            .withThrowExceptions(false)
            .withOrderedResults(false)
            .build();
    headerCsvBuilder.write(outputHeader);

StatefulBeanToCsv csvBuilderTransactions = new StatefulBeanToCsvBuilder(writer)
            .withThrowExceptions(false)
            .withOrderedResults(false)
            .build();
    csvBuilderTransactions.write(samplesList);

How do I output this without printing a header each time?

Interlated
  • 5,108
  • 6
  • 48
  • 79

1 Answers1

1

Put the annotation

 @CsvBindByPosition(position = 0)

On the bean being serialised.

Interlated
  • 5,108
  • 6
  • 48
  • 79
  • I want to generate header and use CsvBindByPosition. any suggestions – Neo Ravi Feb 23 '20 at 19:43
  • Did you try the format that the question has? That produces a header. – Interlated Feb 24 '20 at 05:01
  • In Question Format, we have to give the headers name manually right. And I am generating using HeaderColumnNameTranslateMappingStrategy implemented by my class and i am also using @CsvBindByName(column = "Column Name" ). so i did not . I need Custom column name , custom column order and Headers – Neo Ravi Feb 24 '20 at 06:39
  • The headerCsvBuilder in this case creates a summary row. Probably not what you are looking for. More relevant https://stackoverflow.com/questions/46072947/statefulbeantocsv-with-column-headers – Interlated Feb 25 '20 at 01:53