(Tcl) 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.
load ./chilkat.dll
set success 0
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
# .xlsx files are Zip archives
set zip [new_CkZip]
set success [CkZip_OpenZip $zip "qa_data/excel/fakeCompanies.xlsx"]
if {$success == 0} then {
puts [CkZip_lastErrorText $zip]
delete_CkZip $zip
exit
}
set csv [new_CkCsv]
set sheetNames [new_CkStringTable]
set success [CkCsv_XlsxGetSheets $csv $zip $sheetNames]
if {$success == 0} then {
puts [CkCsv_lastErrorText $csv]
delete_CkZip $zip
delete_CkCsv $csv
delete_CkStringTable $sheetNames
exit
}
set i 0
while {$i < [CkStringTable_get_Count $sheetNames]} {
puts [CkStringTable_stringAt $sheetNames $i]
set i [expr $i + 1]
}
delete_CkZip $zip
delete_CkCsv $csv
delete_CkStringTable $sheetNames
|