first let me apologize for my weird and out of place node titles, I will follow protocol from now on.
ok so heres the code I have. Everything works for the most part. Except in the very end where I am trying to write the values from column a and b where a didnt match d. You can see that in the elsif conditions. For some reason it doesnt filter out those values that didnt match, and write them to the "newproduct" spreadsheet. it just writes all of column A and B from the source worksheet to the created one. all 3711 lines of it. heres the whole script:
#!/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 $!; my $workbook1 = Spreadsheet::WriteExcel->new('newproduct.xls'); my $worksheet1 = $workbook1->add_worksheet(); 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 $write_row = 1; for my $row (1..$row_max){ my $valA = $sheet->{Cells}[$row][0]->{Val}; my $valB = $sheet->{Cells}[$row][1]->{Val}; # ... $worksheet1->write ($write_row, 0, "$valA"); $worksheet1->write ($write_row, 1, "$valB"); $write_row++; # ... } } }
I have literally been writing, reading, posting in desperation, lather, rinse, repeat since 9 am. If someone could take a look at this code and my problem and offer some help, id be grateful.
thank you
In reply to can you help with Spreadsheet::WriteExcel module? by trickyq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |