# print "INFO Populating label maps...\n";
for my $worksheet ( $labelWorkbook->worksheets() ) {
my ( $row_min, $row_max ) = $worksheet->row_range();
my ( $col_min, $col_max ) = $worksheet->col_range();
for my $worksheet ( $labelWorkbook->worksheets() ) {
#
# Read Label List (Label_List.xls)
# Spec calls this Label_List.xls
# but file is actually called Label-List.xls
# Please note dash in filename versus underscore and change accordingly
# when/if appropriate
#
my $labelParser = Spreadsheet::ParseExcel->new();
my $labelWorkbook = $labelParser->parse(
File::Spec->catpath( $VOLUME,
$SRCDIR,
'Label-List.xls') );
#!/usr/bin/perl -w
use strict;
use File::Spec;
use Spreadsheet::ParseExcel;
use Spreadsheet::WriteExcel;
#
# Set source dir /dst dir setting
#
my $VOLUME = 'C';
my $SRCDIR = '/Users/Stephen/Desktop/LCMS';
my $DSTDIR = '/Users/Stephen/Desktop/output';
#
# Read files matching "cropped_MB" from DIR
#
opendir DIR, $SRCDIR or die "Could not open dir: $!\n";
my @filelist = grep(/cropped_MB/i, readdir DIR);
closedir DIR;
#
# Read Label List (Label_List.xls)
#
my $labelParser = Spreadsheet::ParseExcel->new();
my $labelWorkbook = $labelParser->parse(
File::Spec->catpath( $VOLUME,
$SRCDIR,
'Label_List.xls') );
#
# Populate label maps to check ranges against.
#
my %startLabelMap;
my %endLabelMap;
# print "INFO Populating label maps...\n";
for my $worksheet ( $labelWorkbook->worksheets() ) {
my ( $row_min, $row_max ) = $worksheet->row_range();
my ( $col_min, $col_max ) = $worksheet->col_range();
for my $row ( $row_min .. $row_max ) {
if($row == 0) {
# Skip first row of label list, these are headers
# print "DEBUG Skipping ".$worksheet->get_cell( $row, 0 )->unformatted()."\n";
next;
}
my $label = $worksheet->get_cell( $row, 0 )->unformatted();
my $start = $worksheet->get_cell( $row, 1 )->unformatted();
my $end = $worksheet->get_cell( $row, 2 )->unformatted();
#!/usr/bin/perl
my $SRCDIR = 'C:/Users/Stephen/Desktop/LCMS';
my $file = $SRCDIR.'/'.'Label-List.xls';
if(-e $file) {
print "File exists\n";
}
NOTE
Be sure to change the SRCDIR and DSTDIR appropriately. They are located at the top of the script.
Be sure to have the perl modules Spreadsheet::ParseExcel and Spreadsheet::WriteExcel installed.
Open in new window