I am using Spreadsheet::WriteExcel to create a spreadsheet with two columns in it. It works. I have one final little problem.
here's the code #!/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}) { # 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 ($row+1, 0, "$valA"); $worksheet->write ($row+1, 1, "$valB"); } } for some reason it puts the values in the new worksheet on the row that it finds them on in the original. So the spreadsheet is 3700 lines long with row after row of blank space. I need it to write to the new spreadsheet without writing the blank cells or matching the row from the original. I hope I described it well. example: If it finds a new product (with the elsif) on row 27 in the original it copies it to row 27 in the new one im creating with the script. If it doesn't find another new product code until row 3200, it will write that to line 3200 on the new one, so I'll have 3173 empty rows. Ive messed with the syntax and am not getting it, i'm sure its something stupid, but I need it to write the values in order, row 1, row 2, etc regardless of where its found in the original. does that make sense? thanks once again -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/