我刚开始使用 Perl,我正在使用
Excel::Writer::XLSX
它来查询 DB2 数据库并将数据导出到 .xlsx 文件。数据约为 250k 行。
该脚本运行良好,但是当我尝试打开 Excel 文件时,它会引发错误并要求修复文件。修复后,一些数据被替换为inf
.
下面是我的代码片段。
while ( my $sqlStatement = ) {
$mSQL = $dbh->prepare( $sqlStatement )
or die "Can't prepare $sqlStatement";
$mSQL->execute()
or die "Can't execute $sqlStatement";
}
my $workbook = Excel::Writer::XLSX->new( $ARGV[2] );
$workbook->set_tempdir( '/tempDir/' );
$workbook->set_optimization();
my $worksheet = $workbook->add_worksheet();
$worksheet->keep_leading_zeros();
my $row = 0;
my $column = 0;
my @emptyRow = ();
$worksheet->write_row( $row++, $column, [ @{ $mSQL->{NAME_uc} } ] );
$worksheet->write_row( $row++, $column, [ @emptyRow ] );
while ( my @Row = $mSQL->fetchrow_array ) {
$worksheet->write_row( $row++, $column, [ @Row ] ); #, $cellFormat);
$count++;
}
$workbook->close();
有人可以就这个问题给我建议吗?