Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Merging worksheets in .xls in one Excel sheet

by poj (Abbot)
on Sep 21, 2017 at 14:51 UTC ( [id://1199843]=note: print w/replies, xml ) Need Help??


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

#!/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"; } } } } } }
poj

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
    Don't bother. This is a case of "i don't understand or bother to read the answers i got and so post the same again". Such people are not worth your tie.


    holli

    You can lead your users to water, but alas, you cannot drown them.

      "You can lead your users to water, but alas, you cannot drown them."

      Please don't consider a career developing software for self driving cars :p

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1199843]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-23 06:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found