Search code examples
clibxl

how to read xlsx files using C


Part of my school project I need to work with LabWindows/CVI.

I need to read a xlsx file and analize it.

I download this libxl library.

I amported the h files and the lib files. this is my code ( I coppied it from here):

#include <cvirte.h>     
#include <userint.h>
#include <formatio.h>
#include "Final work.h"
#include "libxl.h"


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

static int panelHandle;

int readFile()
{
    BookHandle book = xlCreateBook(); // xlCreateXMLBook()
    if (xlBookLoad(book, "G:/Electro data/0.5_time_all.xlsx")){
        return 0;   
    }
    if(book) 
    {
        SheetHandle sheet = xlBookAddSheet(book, L"Sheet1", 0);
        if(sheet) 
        {
            xlSheetWriteStr(sheet, 2, 1, L"Hello, World !", NULL);
            xlSheetWriteNum(sheet, 3, 1, 1000, NULL);
        }
        xlBookSave(book, L"example.xls");
        xlBookRelease(book);
    }
    
    return 0;
}

and I am getting this errors: Build Status (Final work.prj - Debug) Final work.c - 3 warnings

error: Undefined symbol '_xlBookAddSheetA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

error: Undefined symbol '_xlBookLoadA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

error: Undefined symbol '_xlBookReleaseA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

error: Undefined symbol '_xlBookSaveA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

error: Undefined symbol '_xlCreateBookCA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

error: Undefined symbol '_xlSheetWriteNumA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

error: Undefined symbol '_xlSheetWriteStrA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

Build failed.

here is an image to illustrate:

enter image description here

What am I doing wrong?


Solution

  • You need to link with the provided library. From the screenshot you seem to have added the library to your project, however the linker does not get it.