in reply to Merging worksheets in .xls in one Excel sheet
It maybe that your spreadsheets have cells with spaces in which are overwriting earlier spreadsheets. Run this to check
poj#!/usr/bin/perl use strict; use Spreadsheet::ParseXLSX; my $target = 'Target.xlsx'; my @file_list = glob "*xlsx"; my @target=(); for my $file (@file_list){ next if ($file eq $target); print "Scaning $file\n"; my $parser = Spreadsheet::ParseXLSX->new(); my $excel = $parser->parse($file); for my $sheet ( $excel->worksheets ) { my $name = $file ."_".$sheet->get_name; my ( $row_min, $row_max ) = $sheet->row_range(); my ( $col_min, $col_max ) = $sheet->col_range(); for my $row ( $row_min .. $row_max ) { for my $col ( $col_min .. $col_max ) { my $cell = $sheet->get_cell($row,$col) ; if ( $cell ){ my $val = $cell->value; if ($val =~ /\S/){ if ($target[$row][$col]){ print "WARN: Overwriting row: $row col: $col val: '$val' +\n"; } else { $target[$row][$col] = $val; } } else { print "INFO: Skipped blank $name row: $row col: $col value +: '$val'\n"; } } } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Merging worksheets in .xls in one Excel sheet
by holli (Abbot) on Sep 21, 2017 at 15:01 UTC | |
by marto (Cardinal) on Sep 22, 2017 at 08:28 UTC |