Hi naveen,
it is working fine for me if the number of loops from database lessthan 30000.
if the limit increase then file itself is not creating.
following is the coding...... i am getting the problem at saving the file at last line.
i have posted just part of the code.....which is using for generating the excel file..
please look at once and let me know if anything wrong..
Code:
use Spreadsheet::ParseExcel;
use Spreadsheet::WriteExcel;
use Spreadsheet::ParseExcel::SaveParser;
sub generate {
my($dbc, $cgi, $authstring, $LINK, $username, $FUNC2, $LINK2) = @_;
my ($pi_id) = $cgi->param('pi_select');
my($iFmt, $debug);
my $assetpi_xls = 'Report/repor.xls';
$debug = 0;
my $oExcel = new Spreadsheet::ParseExcel::SaveParser;
my $oBook = $oExcel->Parse($assetpi_xls) || die("Parse error: $assetpi_xls");
if(!($oBook)) {
$oBook = Spreadsheet::ParseExcel::Workbook->Parse("$assetpi_xls");
}
if(!($oBook)) {
die ("Error: $assetpi_xls read error");
}
my $time = time;
my $date = localtime($time);
my $oWkS = $oBook->{Worksheet}[0];
my $name = $oWkS->{Name};
my $q;
my $skip = 4;
my($row, $col);
my $query = qq{$query};
my($rows, $count) = $dbc->fetchAll($query);
for my $i (0 .. $#$rows) {
$row = $skip + $i;
$col = -1;
$iFmt = $oBook->{Worksheet}[0]->{Cells}[$row][0];
$oBook->AddCell(0, $row, 0, $row, $iFmt);
foreach my $val (@{ $rows }[$i]) {
$col++;
$iFmt = $oBook->{Worksheet}[0]->{Cells}[$row][$col];
$oBook->AddCell(0, $row, $col, $val, $iFmt);
}
}
$iFmt = $oBook->{Worksheet}[0]->{Cells}[1][7];
$oBook->AddCell(0, 1, 1, $date, $iFmt);
$iFmt = $oBook->{Worksheet}[0]->{Cells}[1][1];
$oExcel->SaveAs($oBook, qq{/tmp/temp.xls.$time}); # time stamped. the streaming funtion will delete this file once complete
// here the file is saving with 0 size and deleting automatically thi is the error i am getting
}