Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use Spreadsheet::XLSX;
- use Text::CSV::Slurp;
- my $excel = Spreadsheet::XLSX -> new ($ARGV[0]);
- my @rows;
- foreach my $sheet (@{$excel -> {Worksheet}}) {
- $sheet -> {MaxRow} ||= $sheet -> {MinRow};
- foreach my $row ($sheet -> {MinRow} .. $sheet -> {MaxRow}) {
- $sheet -> {MaxCol} ||= $sheet -> {MinCol};
- my %cells = ();
- foreach my $col ($sheet -> {MinCol} .. $sheet -> {MaxCol}) {
- my $cell = $sheet -> {Cells} [$row] [$col];
- if ($cell) {
- $cells{"column $col"} = $cell->{Val};
- }
- }
- push @rows, \%cells;
- }
- }
- my $csv = Text::CSV::Slurp->new();
- my $csv = $csv->create(input => \@rows);
- print $csv;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement