性能不错,比phpexcel方便
以下是导出代码:
$excel = new VtifulKernelExcel($config);
// fileName 会自动创建一个工作表,你可以自定义该工作表名称,工作表名称为可选参数
// 第三个参数 False 即为关闭 ZIP64
$fileObject = $excel->constMemory($fileName, 'sheet1Name', false);
$fileHandle = $fileObject->getHandle();
$format = new VtifulKernelFormat($fileHandle);
$boldStyle = $format->bold()->toResource();
// 写入数据前设置行样式
$filePath = $fileObject->setRow('A1', 20, $boldStyle)->freezePanes(1, 0)->header($colsName)->data($excelData)->output();
//Set Header
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header('Content-Disposition: attachment;filename="' . $fileName . '"');
header('Content-Length: ' . filesize($filePath));
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');
header('Cache-Control: max-age=0');
header('Pragma: public');
ob_clean();
flush();
if (copy($filePath, 'php://output') === false) {
// Throw exception
}
// Delete temporary file
@unlink($filePath);
pecl也有,自行搜索。