I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2010-06-17 17:38:35.289484-07 by jaiguevara
spreadsheet optimization
Is it possible to to do mass operations on groups of table cells, for example apply cellValueType(), or cellStyle() to a span, row or column?

I have a large spreadsheet (30K rows, 30 columns) where I'm loading rows from a mySQL query. It seems slow to treat each cell, especially when I know the data types of the columns.

my $X=1; my $Y=0; for my $row ( @$result_rows ) { # database query results for my $fld(@$row) { my $Cell = $doc->getTableCell($sheet, $X, $Y); $doc->cellValueType($Cell, $type); $doc->cellValue($Cell, "$fld"); set_cell_style($Cell); } $Y++; } $X++; $Y=0; }
Any suggestions for improvements would be appreciated.
Direct Responses: 12787 | Write a response
Posted on 2010-06-18 20:21:45.519876-07 by jaiguevara in response to 12782
Re: spreadsheet optimization
Looks like there's no way to set type or style on multiple table cells. The following - getting cell rows and indexing vs getTableCell is much faster. Not a lot of examples out there so maybe this can help someone.
my $doc = odfDocument(file => $output_file, create => 'spreadsheet'); my $sheet = $doc->expandTable(0, $Rows, $Columns); my @tblrows = $doc->getTableRows($sheet); my $X=0; my $Y=0; for my $row ( @$result_rows ) { #DBI fetchall_arrayref results my $tblrow = $tblrows[$X]; my @cells = $doc->getRowCells($tblrow); #get open cells for 1st row for my $fld(@$row) { $doc->cellValueType($cells[$Y], "$type"); $doc->cellValue($cells[$Y], "$fld"); $doc->cellStyle($cells[$Y], "stylename"); } }
Direct Responses: Write a response