You should fix the indentation. Also,
SSCCE should compile, but yours doesn't, as it contains several undeclared variables. I was able to fix it, I also created an input XLSX document with two sheets, one of them called AD-Data containing
1 123456789
2 123456790
3 123456791
4 123456792
5 123456793
6 123456794
7 123456795
8 123456796
and another called syslog_-prod containing
1 2
6 123456789
11 123456790
16 123456791
21 123456792
26 123456793
31 123456794
36 123456795
41 123456796
Running the edited code
#!/usr/bin/perl
use strict;
use warnings;
use Spreadsheet::ParseXLSX;
use Excel::Writer::XLSX;
my $parser = Spreadsheet::ParseXLSX->new;
my $workbook1 = $parser->parse('input.xlsx');
if ( !defined $workbook1 ) {
die $parser->error, ".\n";
}
my $workbook = Excel::Writer::XLSX->new( 'output.xlsx' );
my $worksheet = $workbook->add_worksheet;
my $Synchrony_format = $workbook->add_format(
bold => 0,
color => 'green',
size => 16,
);
my $my_format = $workbook->add_format(
bold => 1,
color => 'blue',
size => 18,
);
my $appsshhetname = "syslog_-prod";
my $ADdata = "AD-Data";
my $row_min = 1;
my $row_max = 5;
my $col_min = 1;
my $col_max = 3;
my $r = 1;
my @cellA;
for my $worksheet1 ($workbook1->worksheets) {
$worksheet->write(0, 0, 'AD Match' , $my_format);
$worksheet->write(0, 2, 'AD MATCH' , $Synchrony_format);
$worksheet->write(0, 3, 'Creation Date' , $Synchrony_format);
my $appssheet = $worksheet1->get_name;
for my $row ( $row_min .. $row_max ) {
for my $col ( $col_min = 0) {
if ( $appssheet eq $appsshhetname ) {
my $cell = $worksheet1->get_cell( $row, 1 );
next unless $cell;
my $cellA = $cell->value;
$cellA =~ s/@(AD.ABC.COM)//g;
push @cellA, $cellA if $cellA=~ /(\d{9})/;
}
my %params = map { $_ => 1 } @cellA;
my @uniq = keys %params;
if ( $appssheet eq $ADdata ) {
for my $row1 ( $row_min .. $row_max ) {
for my $col1 ( $col_min = 1) {
my $cellB = $worksheet1->get_cell( $row, 1 );
next unless $cellB;
my $cellC = $cellB->value;
$worksheet->write($r, 0, $cellC) if exists $pa
+rams{$cellC};
}
}
$r += 1;
}
}
}
}
I got no errors nor warnings and the output file was created with a coloured header and the following contents in the first column:
123456790
123456791
123456792
123456793
but formatted as 1.23E+08.
Sorry, what was your question again?
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.