Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. [SOLVED] Excel Interface with XLW
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Excel Interface with XLW

Scheduled Pinned Locked Moved 3rd Party Software
3 Posts 2 Posters 1.7k 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.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by
    #1

    I used xlw product for a number of years now and it is a great framework. Recently I had to do an add-on that required the usage of Qt. It turned out that, after compiling XLL addon with linked QtCore and instantiation of QCoreApplication, the xll cannot be loaded into excel. Excel complains about the xll having an incompatible format...

    i use Qt 4.8 and the dlls are in the same folder as the addon

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      Copying all the libraries in the system folder solved the problem

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      0
      • J Offline
        J Offline
        julienw
        wrote on last edited by julienw
        #3

        I know it is an old topic but I had a similar issue and I think I have a better solution that could be used for deployment (it works at least for Qt 5.9.3) :

        1. copy all your dll in the xll folder (Qt and anything else)
        2. Add the path of your xll in the system PATH (not the user)
        3. Instantiate an object of QCoreApplication
        4. Define a search path for libraries on the xll folder (resolved the "driver not loaded" for sql for example).
          I noted that when we open an xll, the working directory is not the xll folder but the user folder defined in excel (like <user>/document). So I guess that dll couldn't load on runtime for this reason.
          For finding xll path, I didn't find a way to do it with Qt.
        #include <QCoreApplication>
        #include <windows.h>
        QCoreApplication * g_application = NULL;
        QString getPath()
        {
            char path[100];
            HMODULE hm = NULL;
        
            if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
                    GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
                    (LPCSTR) &getPath,
                    &hm))
            {
                int ret = GetLastError();
                fprintf(stderr, "GetModuleHandle returned %d\n", ret);
            }
            GetModuleFileNameA(hm, path, sizeof(path));
            return QString(path);
        }
        
        class RegisterLibrary
        {
        public:
            int m_argc;
            char ** m_argv;
            RegisterLibrary()
            {
                m_argc = 1;
                m_argv = new char*[2];
                m_argv[0] = new char[30];
                strcpy(m_argv[0], "libExcel");
                m_argv[1] = NULL;
                g_application = new QCoreApplication(m_argc, m_argv);
                QString filePath = getPath();
                QStringList s = filePath.split("\\");
                s.removeLast();
                QString path = s.join("\\");
                QStringList libraries = QCoreApplication::libraryPaths();
                libraries.append(path);
                QCoreApplication::setLibraryPaths(libraries);
            }
            virtual ~RegisterLibrary()
            {
                delete g_application;
                delete [] m_argv[0];
                delete [] m_argv;
                g_application = NULL;
            }
        };
        RegisterLibrary g_library;
        
        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