I have an Excel file in the following format:
Own,Test,Yes,No
ngh,y,4,3
I have a foreach loop that prints out lines of code that I want to append into the bottom of the excel file:
foreach my $val(sort keys %hash) {
my $own = $hash{$val}{own};
my $test = $hash{$val}{test};
my $yes = $hash{$val}{yes};
my $no = $hash{$val}{no};
print "$own, $test, $yes, $no\n";
}
My foreach prints the following:
dfg,n,6,3
hgf,y,7,4
jsd,n,4,2
lbg,y,7,1
nyg,n,7,6
I want to append this print statement to print at the end of my excel sheet so that my excel sheet looks like this:
Own,Test,Yes,No
ngh,y,4,3
dfg,n,6,3
hgf,y,7,4
jsd,n,4,2
lbg,y,7,1
nyg,n,7,6
I have been trying to use WriteExcel
and ParseExcel
but I cannot get anything to print into the excel sheet. Any guidance would be greatly appreciated.
foreach my $val(sort keys %hash) {
my $own = $hash{$val}{own};
my $test = $hash{$val}{test};
my $yes = $hash{$val}{yes};
my $no = $hash{$val}{no};
my $file = "/C:/programs/Desktop/lsa/test.xlsm";
my $workbook = Excel::Writer::XLSX->new($file);
open (my $fh, '>>', $file) or warn "cant open";
print $fh "$own,$test,$yes,$no\n";
}