(Objective-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.
#import <CkoZip.h>
#import <CkoCsv.h>
#import <CkoStringTable.h>
BOOL success = NO;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// .xlsx files are Zip archives
CkoZip *zip = [[CkoZip alloc] init];
success = [zip OpenZip: @"qa_data/excel/fakeCompanies.xlsx"];
if (success == NO) {
NSLog(@"%@",zip.LastErrorText);
return;
}
CkoCsv *csv = [[CkoCsv alloc] init];
CkoStringTable *sheetNames = [[CkoStringTable alloc] init];
success = [csv XlsxGetSheets: zip sheetNames: sheetNames];
if (success == NO) {
NSLog(@"%@",csv.LastErrorText);
return;
}
int i = 0;
while (i < [sheetNames.Count intValue]) {
NSLog(@"%@",[sheetNames StringAt: [NSNumber numberWithInt: i]]);
i = i + 1;
}
|