I have to output some content as CSV file which will be sometimes opened using
applications like ms-excel but other application will also open the same csv.
Now, these are some problem faced if I open the csv file using ms-excel (although excel is
not a proper application to view CSV)-
- If one particular cell has a new line, the csv breaks the record there after as a new row.
- If we add characters such as double quote or comma, it again considers it as another column.
The format of csv is –
"header1", "header2", "header3"
"column1", "column2", "column3"
....
"columnN", "columnN", "columnN"
My problem is, I want to add characters like {" ' , | new line(0x09/0x0a etc)} etc in the columns, without breaking data integrity. I am using java to build the csv content. Can any one provide any solution?
I suggest to take a look at openscv library http://cs.swansea.ac.uk/~csbob/teaching/java/JavaDemoNetbeans/opencsv-2.3/doc/