Hi everybody. I have a simple problem. Need send the c++ output to excel(csv->xls or xls direct) in formated data. I can send the data to excel, but i can´t format that like this: |_ col 1__|___col 2___|___col n____| row 1......|....2row 1 row 2......|....2row 2 row 3......|... 2row n What i can´t, is go to begin in col 2. My code put the data in this way. |_ col 1__|___col 2___|___col n____| row 1 row 2 row n 2row1 2row2 2rown I don´t set this pointer to next columns. If i put the data in the same "for", i can put the data in way i need. Else, i do not. But, the column 2, have a leght biger then column 1, and I need 2 "for" to put the data. Follow the code. C++ Syntax (Toggle Plain Text)
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cstdlib>
#include <stdlib.h>
using namespace std;
class DATA
{
public:
int dados[5];
int dados2[7];
};
int main()
{
DATA c;
for (int i = 0; i < 5; ++i)
{
c.dados[i]= i;
}
for (int i = 0; i < 7; ++i)
{
c.dados2[i]= i;
}
ofstream out;
out.open("data.txt");
out << "DADOS 1"<<",";
for (int i = 0; i < 5; ++i)
{
out << c.dados[i] <<",";
}out<<"\n";
out << "DADOS 2"<<",";
for (int i = 0; i < 7; ++i)
{
out << c.dados2[i] <<",";
}out<<"\n";
system("RELATORIO.xlsx"); //open excel and import a data.txt to format xls
return EXIT_SUCCESS;
} this code put the data in rows, like a |__DATA_1_|__1__|___2__|___3___|__4____|___5____|___N_____| |__DATA_2_|__1__|___2__|___3___|___4___|___5____|___N_____| this is the way I found to get my data, but is not the way I want Any help??