(Unicode C++) XLSX Get Sheet Names
Open an Excel spreadsheet (.xlsx) and get the names of the sheets. Note: This example requires Chilkat v11.3.0 or greater.
#include <CkZipW.h>
#include <CkCsvW.h>
#include <CkStringTableW.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
CkZipW zip;
success = zip.OpenZip(L"qa_data/excel/fakeCompanies.xlsx");
if (success == false) {
wprintf(L"%s\n",zip.lastErrorText());
return;
}
CkCsvW csv;
CkStringTableW sheetNames;
success = csv.XlsxGetSheets(zip,sheetNames);
if (success == false) {
wprintf(L"%s\n",csv.lastErrorText());
return;
}
int i = 0;
while (i < sheetNames.get_Count()) {
wprintf(L"%s\n",sheetNames.stringAt(i));
i = i + 1;
}
}
|