Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to Write more than one data on same cell when export to excell?
Forum Updated to NodeBB v4.3 + New Features

How to Write more than one data on same cell when export to excell?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 352 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mangekoyuM Offline
    mangekoyuM Offline
    mangekoyu
    wrote on last edited by mangekoyu
    #1

    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;
    
      }
    
    Pl45m4P 1 Reply Last reply
    0
    • mangekoyuM mangekoyu

      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;
      
        }
      
      Pl45m4P Online
      Pl45m4P Online
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @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] = Year

      If 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 prints A, A, AAA, A, A, A

      Edit:

      You need to replace j < 7 with j <= 7 or you will never reach your data[7]


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      2
      • mangekoyuM Offline
        mangekoyuM Offline
        mangekoyu
        wrote on last edited by
        #3

        @Pl45m4 When I try to write wıi\'h xlsx.write(k, 4, result, format); it did not accept result. Can you showe me how can I do thıs ıf u know?

        Pl45m4P 1 Reply Last reply
        0
        • mangekoyuM mangekoyu

          @Pl45m4 When I try to write wıi\'h xlsx.write(k, 4, result, format); it did not accept result. Can you showe me how can I do thıs ıf u know?

          Pl45m4P Online
          Pl45m4P Online
          Pl45m4
          wrote on last edited by
          #4

          @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.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved