for my $i ($new->{'minrow'} .. $new->{'maxrow'}){ for my $j ($new->{'mincol'} .. ($new->{'maxcol'} - 1)){ $cell = $worksheetloop->get_cell($i, 0); $CodColab = $cell->value(); $cell = $worksheetloop->get_cell(1, $j); $CodTecno = $cell->value(); $cell = $worksheetloop->get_cell($i, $j); $cellVal = $cell->value(); if(!defined($cell) or $cell->value() eq ""){ $cellVal = 0; } $sqlCom = "INSERT INTO Level (Codigo, Nivel, DataAval, CodColab, CodTecno) VALUES (?, ?, ?, ?, ?)"; $sth = $dbh->prepare($sqlCom); $sth->bind_param(1, $counter); $sth->bind_param(2, $cellVal); $sth->bind_param(3, "2014-02-04"); $sth->bind_param(4, $CodColab); $sth->bind_param(5, $CodTecno); print "$sqlCom\n"; getc(); $sth->execute(); $counter++; } }