Sample code for 30+ languages & platforms
Perl Requires Chilkat v11.3.0+

XLSX Get Sheet Names

Open an Excel spreadsheet (.xlsx) and get the names of the sheets.

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

# .xlsx files are Zip archives
my $zip = Chilkat2::Zip->new;
my $success = $zip->OpenZip('qa_data/excel/fakeCompanies.xlsx');
if (!$success) {
    print $zip->LastErrorText, "\n";
    exit;
}

my $csv = Chilkat2::Csv->new;
my $sheetNames = Chilkat2::StringTable->new;
$success = $csv->XlsxGetSheets($zip, $sheetNames);
if (!$success) {
    print $csv->LastErrorText, "\n";
    exit;
}

my $i = 0;
while ($i < $sheetNames->Count) {
    print $sheetNames->StringAt($i), "\n";
    $i = $i + 1;
}