Correction erreur phpExcel aurel
This commit is contained in:
parent
0ae709972a
commit
a29404398c
|
@ -199,67 +199,66 @@ function xlsx_switch_lvl1($request, $answer){
|
|||
|
||||
//vérificationd des paramètres en entrée
|
||||
|
||||
if(isset($request->formation) && isset($request->groupe) && isset($request->controle) && isset($request->resultat)){
|
||||
// if(isset($request->formation) && isset($request->groupe) && isset($request->controle) && isset($request->resultat)){
|
||||
|
||||
|
||||
// Création de la fiche
|
||||
// // Création de la fiche
|
||||
|
||||
$workbook = new PHPExcel();
|
||||
$sheet = $workbook->getActiveSheet();
|
||||
$writer = new PHPExcel_Writer_Excel2007($workbook);
|
||||
// $workbook = new PHPExcel();
|
||||
// $sheet = $workbook->getActiveSheet();
|
||||
// $writer = new PHPExcel_Writer_Excel2007($workbook);
|
||||
|
||||
// Titre du document
|
||||
// // Titre du document
|
||||
|
||||
$workbook->getProperties()->setTitle($request->formation.$request->groupe.$request->controle);
|
||||
// $workbook->getProperties()->setTitle($request->formation.$request->groupe.$request->controle);
|
||||
|
||||
// Taille des cases
|
||||
// // Taille des cases
|
||||
|
||||
$sheet->getColumnDimension('A')->setWidth(20);
|
||||
$sheet->getColumnDimension('B')->setWidth(20);
|
||||
$sheet->getColumnDimension('C')->setWidth(10);
|
||||
// $sheet->getColumnDimension('A')->setWidth(20);
|
||||
// $sheet->getColumnDimension('B')->setWidth(20);
|
||||
// $sheet->getColumnDimension('C')->setWidth(10);
|
||||
|
||||
// Écriture des colonnes du tableau
|
||||
// // Écriture des colonnes du tableau
|
||||
|
||||
$sheet->setCellValue('A1', $request->groupe);
|
||||
$sheet->setCellValue('B1', date("d/m/Y G:m"));
|
||||
$sheet->setCellValue('C1', $request->controle);
|
||||
$sheet->setCellValue('A3', 'Nom');
|
||||
$sheet->setCellValue('B3', 'Prénom');
|
||||
$sheet->setCellValue('C3', 'Note');
|
||||
// $sheet->setCellValue('A1', $request->groupe);
|
||||
// $sheet->setCellValue('B1', date("d/m/Y G:m"));
|
||||
// $sheet->setCellValue('C1', $request->controle);
|
||||
// $sheet->setCellValue('A3', 'Nom');
|
||||
// $sheet->setCellValue('B3', 'Prénom');
|
||||
// $sheet->setCellValue('C3', 'Note');
|
||||
|
||||
|
||||
// Écriture des valeurs dans le document Excel
|
||||
// // Écriture des valeurs dans le document Excel
|
||||
|
||||
$index = 5;
|
||||
foreach ( $request->resultat as $eleve ) {
|
||||
// $index = 5;
|
||||
// foreach ( $request->resultat as $eleve ) {
|
||||
|
||||
$sheet->setCellValue('A'.$index,$eleve->nom);
|
||||
$sheet->setCellValue('B'.$index,$eleve->prenom);
|
||||
$sheet->setCellValue('C'.$index,$eleve->note);
|
||||
}
|
||||
}
|
||||
//On enregistre ce nouveau fichier, et on lance son téléchargement
|
||||
// $sheet->setCellValue('A'.$index,$eleve->nom);
|
||||
// $sheet->setCellValue('B'.$index,$eleve->prenom);
|
||||
// $sheet->setCellValue('C'.$index,$eleve->note);
|
||||
// }
|
||||
// }
|
||||
// //On enregistre ce nouveau fichier, et on lance son téléchargement
|
||||
|
||||
$docPath = DIRECTORY_SEPARATOR.join(DIRECTORY_SEPARATOR, array("page", "excelTemplates",
|
||||
$request->formation.$request->groupe.$request->controle".xlsx"));
|
||||
if(file_exists (__ROOT__.$docPath)){
|
||||
$index = 1;
|
||||
$titleLen = strlen($docPath) - 5;
|
||||
while(file_exists (__ROOT__.$docPath)){
|
||||
$docPath = mb_strimwidth($docPath, 0, $titleLen, "")." (".$index.").xlsx";
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
$writer->save(__ROOT__.$docPath);
|
||||
$answer->docPath = $docPath;
|
||||
}
|
||||
// $docPath = DIRECTORY_SEPARATOR.join(DIRECTORY_SEPARATOR, array("page", "excelTemplates", $request->formation.$request->groupe.$request->controle".xlsx"));
|
||||
// if(file_exists (__ROOT__.$docPath)){
|
||||
// $index = 1;
|
||||
// $titleLen = strlen($docPath) - 5;
|
||||
// while(file_exists (__ROOT__.$docPath)){
|
||||
// $docPath = mb_strimwidth($docPath, 0, $titleLen, "")." (".$index.").xlsx";
|
||||
// $index++;
|
||||
// }
|
||||
// }
|
||||
// $writer->save(__ROOT__.$docPath);
|
||||
// $answer->docPath = $docPath;
|
||||
// }
|
||||
|
||||
// Erreur de paramètre(s)
|
||||
// // Erreur de paramètre(s)
|
||||
|
||||
else {
|
||||
// else {
|
||||
|
||||
$answer->request = 'param_error';
|
||||
}
|
||||
// $answer->request = 'param_error';
|
||||
// }
|
||||
|
||||
break;
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue