Home » excel » c++ – CSV not formatting correctly

c++ – CSV not formatting correctly

Posted by: admin May 14, 2020 Leave a comment

Questions:

I am trying to post the following into a .csv file.

 stream<<"DesiredV"<<'\t'<<" Charge V "<<'\t'<<" Charge Current "<<'\t'<<"Float Voltage"<<'\r\n';

However, \t isn’t tabbing over to the next column and \r\n isn’t moving to the next row. I am opening the .csv with excel and using Qt.

How to&Answers:

.csv files (Comma-separated values) use Comma , to seperate columns (http://en.wikipedia.org/wiki/Comma-separated_values)

So you should change all '\t' to ','

And you should use "\r\n" instead of '\r\n'.
'\r\n' will be regarded as '\r' by compiler.