我使用PHPExcel_1.7.9库以.xlsx格式导出数据。该库包含223个文件和53个文件夹。我想要的文件和文件夹只对我的功能有用(避免在服务器上上传不必要的文件)。
贝娄是代码,工作得很好。
//----CODE TO EXPORT DATA DIRECTLY AS EXCEL(.XLSX) WITHOUT HELP OF CSV FORMAT ----------
require_once ROOT_PATH . '/Classes/PHPExcel.php';
$header=$exportPlugin->getCommonHeader($case,$frmDate,$toDate,$empid,$divId,$excpCode,$reportType,$varType);
$data=$exportPlugin->getCommonFilterData($case,$frmDate,$toDate,$empid,$divId,$excpCode,$reportType,$varType);
$base_path1 = dirname(__FILE__);
$lastSpacePosition1 = strrpos($base_path1,"\lib");
$base_path1 = substr($base_path1,0,$lastSpacePosition1);
$csvName=str_replace(':','',$csvName);
$pathh=$base_path1.'\fileexports\\'.$csvName.".xlsx";
//file_put_contents($pathh, $csvContents);
$objPHPExcel=new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$alpha=Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
$objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
for($i=0;$igetActiveSheet()->setCellValue($alpha[$i].'1' , $header[$i]);
}
$n=3;
for ($i = 0; $i getActiveSheet()->setCellValue($alpha[$j]. $n, $data[$i][$j]);
}
$n++;
}
foreach(range('A','Z') as $columnID) {
$objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,'Excel2007');
$objWriter->save($pathh);
ob_end_clean();
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment; filename='. $pathh);
header('Cache-Control: max-age=0');
readfile($pathh);
unlink($pathh);
//-----------------------------------------------------------------------------------------
请告诉我PHPExcel库中有多少文件或文件夹,我应该保留在项目中,哪些可以删除?
工作环境 -
.......服务器 - XAMPP
............ Apache / 2.2.11(Win32)DAV / 2 mod_ssl / 2.2.11 OpenSSL / 0.9.8i PHP / 5.2.9
............ MySQL客户端版本:5.0.51a
............ PHP扩展名:mysql
....... O.S - WINDOWS7
答案 0 :(得分:0)
如果你绝对必须这样做:
删除除/ en子目录中的所有语言环境文件。删除所有已命名的读者和编写器以及相关的子目录,除了您需要的子目录(但仍需要摘要和接口)。删除除Memory / Icache / CacheBase之外的所有CachedObjectStorage选项。如果您不使用它们,请删除图表。删除共享PCLZip,OLE文件和Escher ....并希望我没有错误计算