Revision #7 has been created by Scott_Huang on Jun 16, 2015, 4:11:48 PM with the memo:
correct one error.
« previous (#6)
Changes
Title
unchanged
Export query content to excel through any of your controllers, also can set cssClass for header/odd/even rows, auto download
Category
unchanged
Tutorials
Yii version
unchanged
Tags
unchanged
Hzl, Excel, Export, Download, Behavior, ScottHuangZL
Content
changed
[...]
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$tempDir = Yii::getAlias('@webroot') . '/uploads/temp/';
if (!is_dir($tempDir)) {
mkdir(Yii::getAlias('@webroot').'/uploads');//need 2 steps to avoid error
mkdir($tempDir);
chmod($tempDir, 0755);
// the default implementation makes it under 777 permission, which you could possibly change recursively before deployment, but here's less of a headache in case you don't
}
$file_name = $tempDir . yii::$app->user->identity->username . '-' . str_replace(array('/', '*', '?', '\\', ':', '[', ']'), array('_', '_', '_', '_', '_', '_', '_'), $excel_file) . '-' . date('Ymd-His') . '.xlsx';[...]