0

I want to color the first row of csv file as first row contains header and i want to show it separately for user convenience.

scrit
  • 241
  • 1
  • 5
  • 12
  • 3
    csv is a plain text file, without formatting options. You should change to some other, more rich format. Check http://howtodoinjava.com/2013/06/19/readingwriting-excel-files-in-java-poi-tutorial/ for a sample – BigMike Aug 21 '14 at 12:24

3 Answers3

3

First of all, CSV has no way of specify formatting options, it's a plain text file containing just the data. In order to add formatting you need to choose another format (may it be XLS, XLSX or just plain HTML).

In your code snippet, you use a jsp, that can be a good solution if you decide to emit HTML, but then again, you should use iteration tags on data and hardcode the HTML marckups in the jstp instead of emitting the document entirely.

If you plan to provide a download like in excel format, a servlet will be probably a better choice.

If you decide for excel compatible format you can use Apache POI to emit the document.

You can read here for a sample on how using a Servlet to emit a CSV.

Community
  • 1
  • 1
BigMike
  • 6,683
  • 1
  • 23
  • 24
1

CSV (comma separated values) are indeed just that: values. There's no way to include formatting in a CSV file

Luca B.
  • 638
  • 4
  • 13
1

CSV is a plain text file. We cannot add formatting like color,font etc..,

If you want to add color, use xls or xlsx.

SANN3
  • 9,459
  • 6
  • 61
  • 97