我在mysql数据库中有一个包含20列和1000000行的表。我曾尝试使用phpexcel将其导出到.xls文件中但是它会降低系统速度并且导出的文件已损坏。请帮助我使用php导出它
set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/');
include 'PHPExcel/IOFactory.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$Qry= $con -> query("SELECT * FROM `table_1`");
$fn="excel_report";
$rowCount = 1;
$objPHPExcel->getActiveSheet()->SetCellValue('A'.$rowCount,'COL 1')->getStyle('A'.$rowCount)->applyFromArray($headerColor);
$objPHPExcel->getActiveSheet()->SetCellValue('B'.$rowCount,'COL 2')->getStyle('B'.$rowCount)->applyFromArray($headerColor);
$objPHPExcel->getActiveSheet()->SetCellValue('C'.$rowCount,'COL 3')->getStyle('C'.$rowCount)->applyFromArray($headerColor);
$objPHPExcel->getActiveSheet()->SetCellValue('D'.$rowCount,'COL 4')->getStyle('D'.$rowCount)->applyFromArray($headerColor);
$objPHPExcel->getActiveSheet()->SetCellValue('E'.$rowCount,'COL 5')->getStyle('E'.$rowCount)->applyFromArray($headerColor);
while($row=$Qry->fetch_array()){
$rowCount++;
$col_1=$row['col_1'];
$col_2=$row['col_2'];
$col_3=$row['col_3'];
$col_4=$row['col_4'];
$col_5=$row['col_5'];
$objPHPExcel->getActiveSheet()->SetCellValue('A'.$rowCount, $col_1)->getStyle('A'.$rowCount)->applyFromArray($allBorder);
$objPHPExcel->getActiveSheet()->SetCellValue('B'.$rowCount, $col_2)->getStyle('B'.$rowCount)->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->SetCellValue('C'.$rowCount, $col_3)->getStyle('C'.$rowCount)->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->SetCellValue('D'.$rowCount, $col_4)->getStyle('D'.$rowCount)->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->SetCellValue('E'.$rowCount, $col_5)->getStyle('E'.$rowCount)->getAlignment()->setWrapText(true);
}
$sheet = $objPHPExcel->getActiveSheet();
$cellIterator = $sheet->getRowIterator()->current()->getCellIterator();
$cellIterator->setIterateOnlyExistingCells( true );
foreach( $cellIterator as $cell ) {
$sheet->getColumnDimension( $cell->getColumn() )->setAutoSize( true );
$sheet->getStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$sheet->getStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');