How to Write more than one data on same cell when export to excell?
-
I'm us'ng Qxlsx for export data to excell. Day, month and year data are not coming as a whole, but separately. I can print them one by one while printing them in excel. How can I combine these 3 data and print it?
here is my code for export
for (i = 0; i < maxRowCount; ++i) // get maximum data row { //strList.clear(); for (j = 0; j < 7; ++j) { /* j[0] = Temp Değeri j[1] = Humadity j[2] = Day j[3] = moon j[4] = Year j[5] = Second j[6] = Minute j[7] = Hour */ if (i < dataColums[j].count()) { format.setNumberFormatIndex(2); // for save as number format if (j == 0) { xlsx.write(k, 3, dataColums[j][i], format); } else if(j==1) { xlsx.write(k, 4, dataColums[j][i], format); } else if(j==2 ) { //here I need write day moon and year when j=2 But I cannot write 3 data on same time. } } k = k + 1; }
-
@mangekoyu said in How to Write more than one data on same cell when export to excell?:
j[2] = Day
j[3] = moon
j[4] = YearIf day, month and year are always the third, fourth and fifth value (index 2 to 4), make a check against them in your for loop and combine them.
Like:for (j = 0; j <= 7; ++j) { string result; if (j == 2) { j = 4; // to prevent double entries and skip date in regular loop for (int jj = 0; jj < 3; jj++){ result += data[2+jj]; } else{ result = data[j]; } } // print result }
If your data is like
{A, A, A, A, A, A, A, A}
, it printsA, A, AAA, A, A, A
Edit:
You need to replace
j < 7
withj <= 7
or you will never reach yourdata[7]
-
@mangekoyu said in How to Write more than one data on same cell when export to excell?:
xlsx.write(k, 4, result, format);
result
is only a variable in my example. You need to change it, so it fits to your code.