I have one final question concerning spreadsheet::xlsx
I have been writing a price list updater and with help and alot of reading I have a pretty badass little script. Thank you to all
my next question should be reasonably simple. Of Course its the things that seem the most simple that I seem to struggle with.
Heres the script so you can see what I am talking about
#!/usr/bin/perl use strict; use Spreadsheet::XLSX; my $excel = Spreadsheet::XLSX -> new ('build.xlsx'); my $sheet = $excel->Worksheet('Sheet1'); my ($row_min,$row_max) = $sheet->row_range(); my %colD=(); for my $row ($row_min..$row_max){ my $valD = $sheet->{Cells}[$row][3]->{Val}; $colD{$valD} = $row+1; # excel row number } 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"; } elsif (!exists $colD{$valA}) { open FILE2, '>','newproducts.txt' or die $!; my $valB = $sheet->{Cells}[$row][1]->{Val}; print FILE2 "New Product: = $valA Price = $valB\n"; close FILE2; } }
In the if statement above it takes any instance of a new product id in colA and looks for it in colD. if it finds it anywhere in ColD it puts it in a text file. I need it to take the price it finds in ColB, which is also currently printing to the text file. I need to print that value (the price in colB) to Column R in the corresponding row with column A.
So, if Column A6 has a product code of 12345 and the script finds a match all the way on Column D2341, it will write the price from Column B6 to Column R6.
I cannot find the syntax for writing back to an Excel spreadsheet using Spreadheet::xlsx
thank you
ken
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |