I want to insert a multiline text data in a CSV field.
Ex:
var data = "\nanything\nin\nthis\nfield";
var fields = "\"Datafield1\",\"Datafield2:"+data+"\"\n";
When I save fields
into a csv file and open it using MS Excel, I get to see only the first column. But when I open the file using a text editor I see:
"Datafield1","Datafield2:
anything
in
this
field"
I don't know whether I am going against CSV standards. Even if I am going against Please help me with a workaround.
Thanks...
If you want to write multiple lines in csv file, you can try the sample below. string filePath = @"d:\test. csv"; String delim = ","; StringBuilder outString=new StringBuilder(); outString. Append("\""); //double quote outString.
In order to process the CSV file with values in rows scattered across multiple lines, use option("multiLine",true) .
Cell Character Limits csv files have a limit of 32,767 characters per cell. Excel has a limit of 1,048,576 rows and 16,384 columns per sheet. CSV files can hold many more rows.
Quotation marks appear in CSV files as text qualifiers. This means, they function to wrap together text that should be kept as one value, versus what are distinct values that should be separated out.
By default MS Excel uses semicolon as a separator. use ;
and you'll see this:
Here I place some text followed by the NewLine char followed by some more text and the whole string MUST be quoted into a field in a csv file.
Do not use a CR since EXCEL will place it in the next cell.
""2" + NL + "DATE""
When you invoke EXCEL, you will see this. You may have to auto size the height to see the entire cell.
2
DATE
Here's the code in Basic
CHR$(34,"2", 10,"DATE", 34)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With