Creating headers for CSV file

19,344

Here is your solution :

 CSVWriter csvWrite = new CSVWriter(new FileWriter(csvFile));
 String[] entries = {"eid","name","vid","emp_id","balance_amt","handover_to","entry_date"};
 csvWrite.writeNext(entries);

thats working fine here ! try

Share:
19,344
iam user
Author by

iam user

Updated on June 28, 2022

Comments

  • iam user
    iam user almost 2 years

    I'm writing a CSV file using the Opencsv library and need to add headers to my file. The file is created and the headers are inserted, but all the headers in same cell.

    csvFile.createNewFile();
    CSVWriter csvWrite = new CSVWriter(new FileWriter(csvFile));
    String heading = "eid,name,vid,emp_id,balance_amt,handover_to,entry_date \n";
    csvWrite.writeNext(new String[]{heading});
    
  • iam user
    iam user over 7 years
    if there is any possible way to change the color for header? bcz some one says its possible to do that..
  • Abhinav Saxena
    Abhinav Saxena over 5 years
    Please complete your answer with the library/dependencies (gradle) you are using for this solution, and the configuration code if necessary.
  • Deepak Kumar
    Deepak Kumar over 5 years
    In this question, you'll get the library and just answering the question that @iam user asked.