Sample code for 30+ languages & platforms
C++

XLSX Get Sheet Names

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

Chilkat C++ Downloads

C++
#include <CkZip.h>
#include <CkCsv.h>
#include <CkStringTable.h>

void ChilkatSample(void)
    {
    bool 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
    CkZip zip;
    success = zip.OpenZip("qa_data/excel/fakeCompanies.xlsx");
    if (success == false) {
        std::cout << zip.lastErrorText() << "\r\n";
        return;
    }

    CkCsv csv;
    CkStringTable sheetNames;
    success = csv.XlsxGetSheets(zip,sheetNames);
    if (success == false) {
        std::cout << csv.lastErrorText() << "\r\n";
        return;
    }

    int i = 0;
    while (i < sheetNames.get_Count()) {
        std::cout << sheetNames.stringAt(i) << "\r\n";
        i = i + 1;
    }
    }