Sample code for 30+ languages & platforms
Unicode C

XLSX Get Sheet Names

Open an Excel spreadsheet (.xlsx) and get the names of the sheets.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkZipW.h>
#include <C_CkCsvW.h>
#include <C_CkStringTableW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkZipW zip;
    HCkCsvW csv;
    HCkStringTableW sheetNames;
    int i;

    success = FALSE;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    // .xlsx files are Zip archives
    zip = CkZipW_Create();
    success = CkZipW_OpenZip(zip,L"qa_data/excel/fakeCompanies.xlsx");
    if (success == FALSE) {
        wprintf(L"%s\n",CkZipW_lastErrorText(zip));
        CkZipW_Dispose(zip);
        return;
    }

    csv = CkCsvW_Create();
    sheetNames = CkStringTableW_Create();
    success = CkCsvW_XlsxGetSheets(csv,zip,sheetNames);
    if (success == FALSE) {
        wprintf(L"%s\n",CkCsvW_lastErrorText(csv));
        CkZipW_Dispose(zip);
        CkCsvW_Dispose(csv);
        CkStringTableW_Dispose(sheetNames);
        return;
    }

    i = 0;
    while (i < CkStringTableW_getCount(sheetNames)) {
        wprintf(L"%s\n",CkStringTableW_stringAt(sheetNames,i));
        i = i + 1;
    }



    CkZipW_Dispose(zip);
    CkCsvW_Dispose(csv);
    CkStringTableW_Dispose(sheetNames);

    }