trickyq has asked for the wisdom of the Perl Monks concerning the following question:
Ok Im using the WriteExcel module now. Works fine. I'm just trying to figure out how to populate a whole column. im basically guessing at the syntax here, from what I saw in some examples in cpan. the write stuff is in the last section, the elsif at the bottom
#!/usr/bin/perl use strict; use Spreadsheet::XLSX; use SpreadSheet::WriteExcel; my $excel = Spreadsheet::XLSX -> new ('build.xlsx'); my $sheet = $excel->Worksheet('Sheet1'); my ($row_min,$row_max) = $sheet->row_range(); # scan col D and store values my %colD=(); for my $row ($row_min..$row_max){ my $valD = $sheet->{Cells}[$row][3]->{Val}; $colD{$valD} = $row+1; # excel row number } # scan col A starting at row 2 open FILE,'>','feckyou.txt' or die $!; for my $row (1..$row_max){ my $valA = $sheet->{Cells}[$row][0]->{Val}; # does this value exist in Col D if (exists $colD{$valA}) { my $valB = $sheet->{Cells}[$row][1]->{Val}; my $xlrow = $row+1; print FILE "price change [A$xlrow]=[D$colD{$valA}] Value=$valB\n"; } #output new products to text file elsif (!exists $colD{$valA}) { my $workbook = Spreadsheet::WriteExcel->new('newproduct.xls'); my $worksheet = $workbook->add_worksheet(); # open FILE2, '>','newproducts.txt' or die $!; my $valB = $sheet->{Cells}[$row][1]->{Val}; # print FILE2 "New Product: = $valA Price = $valB\n"; # close FILE2; $worksheet->write (0, $row+1, "$valA"); $worksheet->write (1, $row+1, "$valB"); } }
Im trying to write the results from $valA into column 0, row 0 thru however many new products there are. And the same with $valB which is the prices of the new products. It creates the excel file, but its empty. Once again some fundamental part of this is going by me.
please help
thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: spreadsheet::WriteExcel and whos on first?
by runrig (Abbot) on Jun 05, 2012 at 18:43 UTC | |
|
Re: spreadsheet::WriteExcel and whos on first?
by roboticus (Chancellor) on Jun 05, 2012 at 20:24 UTC | |
|
Re: spreadsheet::WriteExcel and whos on first?
by ww (Archbishop) on Jun 05, 2012 at 21:13 UTC |