PowerBuilder
PowerBuilder
XLSX Get Sheet Names
Open an Excel spreadsheet (.xlsx) and get the names of the sheets.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Zip
oleobject loo_Csv
oleobject loo_SheetNames
integer i
li_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
loo_Zip = create oleobject
li_rc = loo_Zip.ConnectToNewObject("Chilkat.Zip")
if li_rc < 0 then
destroy loo_Zip
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Zip.OpenZip("qa_data/excel/fakeCompanies.xlsx")
if li_Success = 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
return
end if
loo_Csv = create oleobject
li_rc = loo_Csv.ConnectToNewObject("Chilkat.Csv")
loo_SheetNames = create oleobject
li_rc = loo_SheetNames.ConnectToNewObject("Chilkat.StringTable")
li_Success = loo_Csv.XlsxGetSheets(loo_Zip,loo_SheetNames)
if li_Success = 0 then
Write-Debug loo_Csv.LastErrorText
destroy loo_Zip
destroy loo_Csv
destroy loo_SheetNames
return
end if
i = 0
do while i < loo_SheetNames.Count
Write-Debug loo_SheetNames.StringAt(i)
i = i + 1
loop
destroy loo_Zip
destroy loo_Csv
destroy loo_SheetNames