Swift
Swift
XLSX Get Sheet Names
Open an Excel spreadsheet (.xlsx) and get the names of the sheets.Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// .xlsx files are Zip archives
let zip = CkoZip()!
success = zip.open(zipPath: "qa_data/excel/fakeCompanies.xlsx")
if success == false {
print("\(zip.lastErrorText!)")
return
}
let csv = CkoCsv()!
let sheetNames = CkoStringTable()!
success = csv.xlsxGetSheets(xlsx: zip, sheetNames: sheetNames)
if success == false {
print("\(csv.lastErrorText!)")
return
}
var i: Int = 0
while i < sheetNames.count.intValue {
print("\(sheetNames.string(at: i)!)")
i = i + 1
}
}