Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I format data that is to be written in CSV file using java

I have some code to write data into a CSV file, but it writes data into a CSV without formatting it properly. I want to bold some specific text. Is that possible?

like image 406
Tokendra Kumar Sahu Avatar asked May 14 '26 21:05

Tokendra Kumar Sahu


2 Answers

CSV is just a plain text format, so you can't do any formatting.

If you want formatting, consider using an Excel library such as Apache POI or Jasper Reports. (Of course, then you end up with an excel file rather than a CSV, so depending on your situation that may or may not be appropriate)

As a side note, there are some strange nuances to writing CSV (such as making sure quotes, commas etc are properly escaped). There's a nice lightweight library I've used called Open CSV that might make your life easier if you choose to just stick with plain old CSV.

like image 149
Michael D Avatar answered May 17 '26 09:05

Michael D


CSV is a plain text file format, you can not use any text effect.

like image 21
Giuseppe Cardone Avatar answered May 17 '26 11:05

Giuseppe Cardone