如何使用Qt使用C ++编写csv文件(逐个单元格) [英] How to write csv file (cell by cell) using C++ by qt

查看:1191
本文介绍了如何使用Qt使用C ++编写csv文件(逐个单元格)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hallo,我正在尝试使用Qt来创建csv文件。

问题是我在同一个单元格中有所有变量,而我想在自己的单元格中编写每个变量



我尝试过:



hallo , i am trying to wirte csv file using Qt .
the problem is that i have all variables in the same cell , while i want to write each variable in an own cell

What I have tried:

float value1 = 25;
float value2 = 33.2;
float value3 = 38.2;
QFile file("./file.csv");
if (file.open(QFile::WriteOnly|QFile::Truncate))
{
QTextStream stream(&file);
stream <<value1<< "\t"<< value2 <<"\t";
file.close();

推荐答案

格式正确,但最好将标签放在字符串中。结束返回的行。



在哪个应用程序是打开的问题。尝试MS Excel或Open Office Calc。两者都有一个导入辅助,可以显示剩余的问题。
The format is correct, but you better put the tab in a string. End a line with a return.

In which app was the problem of opening. Try MS Excel or Open Office Calc. Both have an import assistent which may show you the remaining problems.


这篇关于如何使用Qt使用C ++编写csv文件(逐个单元格)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆