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. Excel file - loop crashout - c++
Qt 6.11 is out! See what's new in the release blog

Excel file - loop crashout - c++

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 296 Views
  • 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.
  • J Offline
    J Offline
    jakubd
    wrote last edited by
    #1

    Hey, I've got an unusual one today. I am trying to iterate through a list of cities in excel. have been using the LibXL library without any issues thus far. However for some reason if I want to iterate through 2824 rows everything crashes out. The code works for an iteration of 200 but not more. doesn't really matter which 200 indexes in between 1 and 2825, just always crashes out.
    It's a simple loop, nothing much. I thought that maybe the fact that I'm using readStr() makes it consume way more memory so I simplified it just to read it and not store it. same thing. At first I tried a manual way of catching a match (strcmp()) but even if I use an unordered map it doesn't work.
    Please help :)

        Book* book = xlCreateBook();
        book->load("file.xls");
        book->setLocale("UTF-8");
        Sheet* sheet = book->getSheet(0);
        unordered_map<string, string> mp;
        for(int i = 1; i < 2826; i++) {
            mp.insert({std::string(sheet->readStr(i, 6)), std::string(sheet->readStr(i, 3))});
        }
    
    jsulmJ 1 Reply Last reply
    0
    • J jakubd

      Hey, I've got an unusual one today. I am trying to iterate through a list of cities in excel. have been using the LibXL library without any issues thus far. However for some reason if I want to iterate through 2824 rows everything crashes out. The code works for an iteration of 200 but not more. doesn't really matter which 200 indexes in between 1 and 2825, just always crashes out.
      It's a simple loop, nothing much. I thought that maybe the fact that I'm using readStr() makes it consume way more memory so I simplified it just to read it and not store it. same thing. At first I tried a manual way of catching a match (strcmp()) but even if I use an unordered map it doesn't work.
      Please help :)

          Book* book = xlCreateBook();
          book->load("file.xls");
          book->setLocale("UTF-8");
          Sheet* sheet = book->getSheet(0);
          unordered_map<string, string> mp;
          for(int i = 1; i < 2826; i++) {
              mp.insert({std::string(sheet->readStr(i, 6)), std::string(sheet->readStr(i, 3))});
          }
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote last edited by
      #2

      @jakubd How is this related to Qt?
      Did you debug to see where it crashes?
      What type of crash is that?
      Run in debugger and provide more information to answer above questions.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • S Offline
        S Offline
        sales99
        wrote last edited by
        #3

        sheet readStr gives you null as there is
        somewhere no valid data, print index where it crash

        1 Reply Last reply
        0

        • Login

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