1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
<?php
//on inclut la classe nécessaire à la lecture du fichier existant
include 'Classes/PHPExcel/IOFactory.php';
//on instancie un objet de lecture
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
//on charge le fichier qu'on veut lire
$objPHPExcel = $objReader->load("MODELEplanning.xlsx");
//on modifie ce fichier
// là, je souhaiterai écrire une date format jour/jj
$objPHPExcel->getSheet($f)->setCellValueByColumnAndRow(0,$l,$donnees['date_vacations']);
// et là, colorer en rouge le fond d'une case A15
$sheet->getStyle('A15')->applyFromArray(array(
'fill'=>array(
'type'=>PHPExcel_Style_Fill::FILL_SOLID,
'color'=>array(
'argb'=>'ec0f0f'))));
$objPHPExcel->getSheet($f)->setCellValueByColumnAndRow(1,$l,$donnees['nom']);
$donnees = $reponse->fetch();
$objPHPExcel->getSheet($f)->setCellValueByColumnAndRow(2,$l,$donnees['nom']);
$donnees = $reponse->fetch();
$objPHPExcel->getSheet($f)->setCellValueByColumnAndRow(3,$l,$donnees['nom']);
//on crée un nouveau fichier
//$objPHPExcel->getSheet(0)->setCellValueByColumnAndRow(1,11,' ');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
//on le sauve
$objPHPExcel->setActiveSheetIndex(0);
$objWriter->save('PLANNING.xlsx');
header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition:inline;filename=PLANNING.xlsx');
$objWriter->save('php://output'); |
Partager