Important: Please read the Qt Code of Conduct -

[SOLVED] Excel Interface with XLW

  • 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

  • Copying all the libraries in the system folder solved the problem

  • 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;
                (LPCSTR) &getPath,
            int ret = GetLastError();
            fprintf(stderr, "GetModuleHandle returned %d\n", ret);
        GetModuleFileNameA(hm, path, sizeof(path));
        return QString(path);
    class RegisterLibrary
        int m_argc;
        char ** m_argv;
            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("\\");
            QString path = s.join("\\");
            QStringList libraries = QCoreApplication::libraryPaths();
        virtual ~RegisterLibrary()
            delete g_application;
            delete [] m_argv[0];
            delete [] m_argv;
            g_application = NULL;
    RegisterLibrary g_library;

Log in to reply