Skip to content

Instantly share code, notes, and snippets.

@zsan
Created June 4, 2014 02:57
Show Gist options
  • Save zsan/471888f52803ce4e2020 to your computer and use it in GitHub Desktop.
Save zsan/471888f52803ce4e2020 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use Spreadsheet::XLSX;
use Modern::Perl;
use Text::Iconv;
my $converter = Text::Iconv -> new ("utf-8", "windows-1251");
my $excel = Spreadsheet::XLSX -> new ('file.xlsx', $converter);
foreach my $sheet (@{$excel->{Worksheet}}) {
printf("Sheet: %s\n", $sheet->{Name});
$sheet->{MaxRow} ||= $sheet->{MinRow};
foreach my $row ($sheet->{MinRow} .. $sheet->{MaxRow}) {
$sheet->{MaxCol} ||= $sheet->{MinCol};
foreach my $col ($sheet->{MinCol} .. $sheet->{MaxCol}) {
my $cell = $sheet->{Cells}[$row][$col];
if ($cell) {
printf("( %s , %s ) => %s\n", $row, $col, $cell->{Val});
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment