On Thu, May 24, 2012 at 11:41 AM, Ken Furff <frazzmata...@gmail.com> wrote: > I am using the spreadsheet::xlsx module in a script im writing. I need to > extract about 4 columns out of about 60. I need those specific columns for > comparison and updating. I assume that I'll load the data into an array or an > array of arrays for comparison. I am able to extract the contents of the > file, but I cant figure out how to specify just those columns... I'll put the > code i currently have below > > use Spreadsheet::XLSX; > > $excel = Spreadsheet::XLSX -> new ('build.xlsx'); > foreach my $sheet (@{$excel -> {Worksheet}}) { > > printf("Sheet: %s\n", $sheet->{Name}); > $sheet -> {MaxRow} ||=$sheet -> {MinRow}; > > foreach $row ($sheet -> {MinRow} .. $sheet -> {MaxRow}) { > > $sheet -> {MaxCol} ||= $sheet -> {MinCol}; > > foreach $col ($sheet -> {MinCol} .. $sheet -> {MaxCol}) { > > $cell = $sheet -> {Cells} [$row] [$col]; > > if ($cell) { > open FILE, ">>buildop.txt" or die $!; > printf FILE ("(%s , %s) => %s\n", $row, $col, $cell -> {Val}); > close FILE; > } > } > } > } > > this just prints the results to a file so I could examine it and try to > figure out how to get just those columns > help > >
Why not make an array of the columns you want. Then loop through only those columns rather than all columns. I would also recommend that you start your script with: use strict; use warnings; See http://www.perlmonks.org/?node_id=111088 for more info. HTH, Ken -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/