Andre_br has asked for the wisdom of the Perl Monks concerning the following question:
Hello my friends,
I read the post about the reducing memory usage by avoiding the formating data, wich may be causing the crash iīm running into with tables above 5 thousand records. But Iīm having trouble in fitting the code into mine. Can anyone give me a hint on this? Do I have to replace the names of the variables of the sub cell_handler? (wich is the recipe of the post I mentioned).
Thanks a lot!#!/usr/bin/perl -w use CGI qw( :standard); use Spreadsheet::ParseExcel; # The new objects my $q = new CGI; my $oExcel = Spreadsheet::ParseExcel->new( CellHandler => \&cell_handl +er, NotSetCell => 1 ); # McNamara's alternative cell handler sub cell_handler { my $workbook = $_[0]; my $sheet_index = $_[1]; my $row = $_[2]; my $col = $_[3]; my $cell = $_[4]; print $cell->{Val} , "<br>"; # ?? I keep this line? Before that I d +id the processing below... Do I have to move everything up here??? An +d, all these variables have other names below; do I have to replace t +he names or these are just internal names for this odd construction t +o work? (this seems the same construction of the upload_hook I never +understood...) } # The header print $q->header( -type => "text/html"); # Starting the cronometer $start = (times) [0]; # The reading # my $file = "z4kjasdf.xls"; my $file = "acervo15k.xls"; # my $file = "teste1.xls"; my $oBook = $oExcel->Parse($file); my($iR, $iC, $oWkS, $oWkC); my @thisrow; # Just the first worksheet... $oWkS = $oBook->{Worksheet}[0]; for ( $iR = $oWkS->{MinRow} ; defined $oWkS->{MaxRow} && $iR <= $oWkS- +>{MaxRow}; $iR++) { @thisrow = (); for ( $iC = $oWkS->{MinCol}; defined $oWkS->{MaxCol} && $iC <= $oWk +S->{MaxCol}; $iC++) { $oWkC = $oWkS->{Cells}[$iR][$iC]; if ($oWkC) { push (@thisrow, $oWkC->{Val}); } } my ($col1, $col2, $col3, $col4, @othercols) = @thisrow; print "$col1 <br>"; } # Ending the cronometer $end = (times) [0]; print "<b>$iR rows read in " , $end-$start , " seconds";
André
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Spreadsheet::ParseExcel vs alternative Cell Handler
by jmcnamara (Monsignor) on Jan 14, 2005 at 09:19 UTC | |
by Andre_br (Pilgrim) on Jan 15, 2005 at 16:51 UTC | |
by Andre_br (Pilgrim) on Jan 17, 2005 at 15:37 UTC | |
Re: Spreadsheet::ParseExcel vs alternative Cell Handler
by jmcnamara (Monsignor) on Jan 20, 2005 at 16:54 UTC | |
by Andre_br (Pilgrim) on Jan 22, 2005 at 19:35 UTC | |
by Errto (Vicar) on Jan 22, 2005 at 21:33 UTC | |
by Anonymous Monk on Jan 27, 2005 at 18:55 UTC | |
by Tanktalus (Canon) on Jan 22, 2005 at 20:31 UTC | |
by Anonymous Monk on Apr 09, 2007 at 19:54 UTC |
Back to
Seekers of Perl Wisdom