PureBasic
PureBasic
XLSX Get Sheet Names
Open an Excel spreadsheet (.xlsx) and get the names of the sheets.Chilkat PureBasic Downloads
IncludeFile "CkStringTable.pb"
IncludeFile "CkCsv.pb"
IncludeFile "CkZip.pb"
Procedure ChilkatExample()
success.i = 0
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
; .xlsx files are Zip archives
zip.i = CkZip::ckCreate()
If zip.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkZip::ckOpenZip(zip,"qa_data/excel/fakeCompanies.xlsx")
If success = 0
Debug CkZip::ckLastErrorText(zip)
CkZip::ckDispose(zip)
ProcedureReturn
EndIf
csv.i = CkCsv::ckCreate()
If csv.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
sheetNames.i = CkStringTable::ckCreate()
If sheetNames.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkCsv::ckXlsxGetSheets(csv,zip,sheetNames)
If success = 0
Debug CkCsv::ckLastErrorText(csv)
CkZip::ckDispose(zip)
CkCsv::ckDispose(csv)
CkStringTable::ckDispose(sheetNames)
ProcedureReturn
EndIf
i.i = 0
While i < CkStringTable::ckCount(sheetNames)
Debug CkStringTable::ckStringAt(sheetNames,i)
i = i + 1
Wend
CkZip::ckDispose(zip)
CkCsv::ckDispose(csv)
CkStringTable::ckDispose(sheetNames)
ProcedureReturn
EndProcedure