Page 1 sur 1

PHPExcel et graph

Posté : 02 juin 2014, 12:29
par moimeme30
Bonjour à tous,

J'utilise PHPExcel pour extraire les données de la BDD sous format excel.
Jusque la, tout va bien. Le problème intervient lorsque je veux enregistrer les résultats sous forme de graph.
Le tableau est bien rempli, mais aucun des cellules ne sont prises en compte pour le graph (voir image)Image

Et voici le code
$objPHPExcel = new PHPExcel();
$objWorksheet = $objPHPExcel->getActiveSheet();
$query = Cnx::connectCnx()->query("SELECT year(date_vente) an1,
				SUM(CASE WHEN MONTH(date_vente) = 1 THEN ttc/(1+(tva/100)) ELSE 0 END) Jan,    
				SUM(CASE WHEN MONTH(date_vente) = 2 THEN ttc/(1+(tva/100)) ELSE 0 END) Fev,    
				SUM(CASE WHEN MONTH(date_vente) = 3 THEN ttc/(1+(tva/100)) ELSE 0 END) Mar,
				SUM(CASE WHEN MONTH(date_vente) = 4 THEN ttc/(1+(tva/100)) ELSE 0 END) Avril,
				SUM(CASE WHEN MONTH(date_vente) = 5 THEN ttc/(1+(tva/100)) ELSE 0 END) Mai,
				SUM(CASE WHEN MONTH(date_vente) = 6 THEN ttc/(1+(tva/100)) ELSE 0 END) Juin,
				SUM(CASE WHEN MONTH(date_vente) = 7 THEN ttc/(1+(tva/100)) ELSE 0 END) Juil,
				SUM(CASE WHEN MONTH(date_vente) = 8 THEN ttc/(1+(tva/100)) ELSE 0 END) Aout,
				SUM(CASE WHEN MONTH(date_vente) = 9 THEN ttc/(1+(tva/100)) ELSE 0 END) Sept,
				SUM(CASE WHEN MONTH(date_vente) = 10 THEN ttc/(1+(tva/100)) ELSE 0 END) Oct,
				SUM(CASE WHEN MONTH(date_vente) = 11 THEN ttc/(1+(tva/100)) ELSE 0 END) Nov,
				SUM(CASE WHEN MONTH(date_vente) = 12 THEN ttc/(1+(tva/100)) ELSE 0 END) `Dec`, 
				SUM(ttc/(1+(tva/100))) as Total
				FROM contacts  WHERE id_societe=17 AND YEAR(date_vente) NOT LIKE '0'  GROUP BY an1");

					for($i=0;$i<=13;$i++){
							$styleA = $objWorksheet->getStyleByColumnAndRow($i,1);
							$styleA->applyFromArray(array(
							'font'=>array(
								'bold'=>true),
							));
					}
											
                $objWorksheet->setCellValueByColumnAndRow(0,1,'Annee' );
                $objWorksheet->setCellValueByColumnAndRow(0,2,'Janv' );
				$objWorksheet->setCellValueByColumnAndRow(0,3,'fev' );
                $objWorksheet->setCellValueByColumnAndRow(0,4,'mars' );
				$objWorksheet->setCellValueByColumnAndRow(0,5,'avril' );
                $objWorksheet->setCellValueByColumnAndRow(0,6,'mai' );
				$objWorksheet->setCellValueByColumnAndRow(0,7,'juin' );
                $objWorksheet->setCellValueByColumnAndRow(0,8,'juillet' );
				$objWorksheet->setCellValueByColumnAndRow(0,9,'aout' );
                $objWorksheet->setCellValueByColumnAndRow(0,10,'sept' );
				$objWorksheet->setCellValueByColumnAndRow(0,11,'oct' );
                $objWorksheet->setCellValueByColumnAndRow(0,12,'nov' );
                $objWorksheet->setCellValueByColumnAndRow(0,13,'dec' );
                $objWorksheet->setCellValueByColumnAndRow(0,14,'total' );

				
                $colonne = 1;
                while($data = $query->fetch()){
                        $ligne=1;	
                        $objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['an1']);$ligne++;
                        $objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Jan']);$ligne++;
                        $objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Fev']);$ligne++;
						$objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Mar']);$ligne++;
                        $objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Avril']);$ligne++;
						$objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Mai']);$ligne++;
                        $objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Juin']);$ligne++;
						$objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Juil']);$ligne++;
                        $objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Aout']);$ligne++;
						$objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Sept']);$ligne++;
                        $objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Oct']);$ligne++;
						$objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Nov']);$ligne++;
                        $objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Dec']);$ligne++;
                        $objWorksheet->setCellValueByColumnAndRow($colonne, $ligne, $data['Total']);
                        
                        $colonne++;//ligne suivante					
						}

//	Set the Labels for each data series we want to plot
//		Datatype
//		Cell reference for data
//		Format Code
//		Number of datapoints in series
//		Data values
//		Data Marker
$dataSeriesLabels = array(
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$1', NULL, 1),	
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$2', NULL, 1),	//	janv
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$3', NULL, 1),	//	fev
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$4', NULL, 1),	//	mars
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$5', NULL, 1),	//	avril
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$6', NULL, 1),	//	mai
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$7', NULL, 1),	//	juin
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$8', NULL, 1),	//	juill
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$9', NULL, 1),	//	aout
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$10', NULL, 1),	//	sept
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$11', NULL, 1),	//	oct
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$12', NULL, 1),	//	nov
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$13', NULL, 1),	//	dec
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$14', NULL, 1),	//	total
);
//	Set the X-Axis Labels
//		Datatype
//		Cell reference for data
//		Format Code
//		Number of datapoints in series
//		Data values
//		Data Marker
$xAxisTickValues = array(
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$B$1:$C$1', NULL, 2),	//	2012 a 2015
);
//	Set the Data values for each data series we want to plot
//		Datatype
//		Cell reference for data
//		Format Code
//		Number of datapoints in series
//		Data values
//		Data Marker
$dataSeriesValues = array(
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$2:$C$2', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$3:$C$3', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$4:$C$4', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$5:$C$5', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$6:$C$6', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$7:$C$7', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$8:$C$8', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$9:$C$9', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$10:$C$10', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$11:$C$11', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$12:$C$12', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$13:$C$13', NULL, 2),
);

//	Build the dataseries
$series = new PHPExcel_Chart_DataSeries(
	PHPExcel_Chart_DataSeries::TYPE_LINECHART,		// plotType
	PHPExcel_Chart_DataSeries::GROUPING_STACKED,	// plotGrouping
	range(0, count($dataSeriesValues)-1),			// plotOrder
	$dataSeriesLabels,								// plotLabel
	$xAxisTickValues,								// plotCategory
	$dataSeriesValues								// plotValues
);

//	Set the series in the plot area
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series));
//	Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_TOPRIGHT, NULL, false);

$title = new PHPExcel_Chart_Title('Test Stacked Line Chart');
$yAxisLabel = new PHPExcel_Chart_Title('Value ($k)');


//	Create the chart
$chart = new PHPExcel_Chart(
	'chart1',		// name
	$title,			// title
	$legend,		// legend
	$plotArea,		// plotArea
	true,			// plotVisibleOnly
	0,				// displayBlanksAs
	NULL,			// xAxisLabel
	$yAxisLabel		// yAxisLabel
);

//	Set the position where the chart should appear in the workobjWorksheet
$chart->setTopLeftPosition('F2');
$chart->setBottomRightPosition('M16');

//	Add the chart to the workobjWorksheet
$objWorksheet->addChart($chart);


// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setIncludeCharts(TRUE);
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;

Re: PHPExcel et graph

Posté : 02 juin 2014, 14:32
par chapt0011
Visiblement selon la doc, le constructeur de PHPExcel_Chart_DataSeriesValues prend 6 paramètres
/**
          * Create a new PHPExcel_Chart_DataSeriesValues object
          */
         public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null)
         {
                $this->setDataType($dataType);
                $this->_dataSource = $dataSource;
                 $this->_formatCode = $formatCode;
                 $this->_pointCount = $pointCount;
                 $this->_dataValues = $dataValues;
                 $this->_marker = $marker;
        }
et quand tu fais
new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$2:$C$2', NULL, 2),
il n'y en a que 4
donc tu ne définit que les sources pas les valeurs... On est d'accord ça devrait se faire automatiquement en appelant une joli foncrion, sauf que la librairie que tu utilises n'a pas l'air totalement terminé:
Comme tu peux le voir, le raffraichissement automatique est remplacé par un joli //TODO... :-)
/**
          * Set Series Data Source (formula)
          *
          * @param       string  $dataSource
          * @return      PHPExcel_Chart_DataSeriesValues
          */
         public function setDataSource($dataSource = null, $refreshDataValues = true) {
                 $this->_dataSource = $dataSource;
 
                 if ($refreshDataValues) {
                         //      TO DO
                 }
                 return $this;
        }
 
donc à par définir toi même les valeurs à afficher dans le graphique, je ne sais pas s'il y a une solution à ton problème!

Re: PHPExcel et graph

Posté : 02 juin 2014, 14:50
par moimeme30
Merci de ta réponse... par contre ca me met un peu dans la m..... :shock:
Mais ce que je ne comprend pas, alors c'est pourquoi lorsque les données ne sont pas issues de la BDD mais directement dans le code
$objPHPExcel = new PHPExcel();
$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet->fromArray(
	array(
		array('',	2010,	2011,	2012),
		array('Q1',   12,   15,		21),
		array('Q2',   56,   73,		86),
		array('Q3',   52,   61,		69),
		array('Q4',   30,   32,		0),
	)
);
Le graph est bien réalisé.
Image

Re: PHPExcel et graph

Posté : 02 juin 2014, 15:11
par chapt0011
Dans ce cas tu n'as qu'à générer l'array à partir de ta requête avec quelques semonces d'array_push()
et puis Worksheet->fromArray() et le tour est joué ;)

Re: PHPExcel et graph

Posté : 02 juin 2014, 15:17
par moimeme30
heuuuu d'accord, tu as un exemple???? car la je galère... :oops:

Re: PHPExcel et graph

Posté : 02 juin 2014, 15:56
par chapt0011
$sheet=array(); // l'array globale
$line=array('Année','Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Aout','Septembre','Octobre','Novembre','Decembre'); //une ligne avec les titres..
array_push($sheet,$line);

//puis ta requête

//
while($data = $query->fetch(PDO::FETCH_BOTH)){
$line=array();//on réinitialise la ligne
array_push($line,$data['an1']);//on rempli chaque colonne de la ligne
array_push($line,$data['Jan']);//....
array_push($line,$data['Fev']);
array_push($line,$data['Avril']);
array_push($line,$data['Mai']);
array_push($line,$data['Juin']);
array_push($line,$data['Juil']);
array_push($line,$data['Aout']);
array_push($line,$data['Sept']);
array_push($line,$data['Oct']);
array_push($line,$data['Nov']);
array_push($line,$data['Dec']);
array_push($line,$data['Total']);//... jusqu'ici
array_push($sheet,$line);//puis on met la ligne dans notre feuille
}

//et finalement:
$objPHPExcel = new PHPExcel();
$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet->fromArray($sheet);

//ATTENTION J'ai mis les données en ligne et non en colonne, ça change surement qqch pour la suite!!

Re: PHPExcel et graph

Posté : 02 juin 2014, 17:03
par moimeme30
Merci de ton aide chapt0011, mais effectivement ca me retourne sous forme de ligne et donc plus rien ne fonctionne, j'ai besoin de le faire sous forme de colonne.
J'ai donc testé
$colonne=array(
			array('Année'),
			array('Janvier'),
			array('Février'),
			array('Mars'),
			array('Avril'),
			array('Mai'),
			array('Juin'),
			array('Juillet'),
			array('Aout'),
			array('Septembre'),
			array('Octobre'),
			array('Novembre'),
			array('Decembre'),
		);
Mais c'est pas ça non plus......
j'ai chaud aux oreilles....

Re: PHPExcel et graph

Posté : 02 juin 2014, 17:22
par chapt0011
Pourtant si simple...
ajoute ça a mon code après le while():
$finalsheet=array();
foreach($sheet as $value) {
    foreach($value as $k=>$v) {
        $finalsheet[$k][]=$v;
    }
}
 //et utilise finalsheet dans le fromArray()

Re: PHPExcel et graph

Posté : 02 juin 2014, 17:39
par moimeme30
Merci, ca fonctionne..... sauf que le graph ne se fait toujours pas.....
Comme si la conception du graph se faisait en ne prenant pas en compte les données... pfffff
Je crois que je vais abandonner...
En tout cas je te remercie chapt0011

Re: PHPExcel et graph

Posté : 02 juin 2014, 17:42
par chapt0011
Sinon j'ai une idée qui me vient la comme ça... essaye en remplaçant les ',' par des '.' dans les données que tu met dans les cellules, c'est peut être de la que vient le problème ?!

Re: PHPExcel et graph

Posté : 02 juin 2014, 17:59
par moimeme30
Non, ca ne fait que planter tout le code....
Je remet le code qui fonctionne et ensuite celui qui ne fonctionne pas.... Si ça aide quelqu'un prochainement.
require_once 'Classes/PHPExcel.php';


$objPHPExcel = new PHPExcel();
$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet->fromArray(
	array(
		array('',	2010,	2011,	2012),
		array('Q1',   12,   15,		21),
		array('Q2',   56,   73,		86),
		array('Q3',   52,   61,		69),
		array('Q4',   30,   32,		0),
	)
);

//	Set the Labels for each data series we want to plot
//		Datatype
//		Cell reference for data
//		Format Code
//		Number of datapoints in series
//		Data values
//		Data Marker
$dataSeriesLabels = array(
	new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1),	//	2010
	new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1),	//	2011
	new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1),	//	2012
);
//	Set the X-Axis Labels
//		Datatype
//		Cell reference for data
//		Format Code
//		Number of datapoints in series
//		Data values
//		Data Marker
$xAxisTickValues = array(
	new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4),	//	Q1 to Q4
);
//	Set the Data values for each data series we want to plot
//		Datatype
//		Cell reference for data
//		Format Code
//		Number of datapoints in series
//		Data values
//		Data Marker
$dataSeriesValues = array(
	new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4),
	new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
	new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4),
);

//	Build the dataseries
$series = new PHPExcel_Chart_DataSeries(
	PHPExcel_Chart_DataSeries::TYPE_LINECHART,		// plotType
	PHPExcel_Chart_DataSeries::GROUPING_STACKED,	// plotGrouping
	range(0, count($dataSeriesValues)-1),			// plotOrder
	$dataSeriesLabels,								// plotLabel
	$xAxisTickValues,								// plotCategory
	$dataSeriesValues								// plotValues
);

//	Set the series in the plot area
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series));
//	Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_TOPRIGHT, NULL, false);

$title = new PHPExcel_Chart_Title('Test Stacked Line Chart');
$yAxisLabel = new PHPExcel_Chart_Title('Value ($k)');


//	Create the chart
$chart = new PHPExcel_Chart(
	'chart1',		// name
	$title,			// title
	$legend,		// legend
	$plotArea,		// plotArea
	true,			// plotVisibleOnly
	0,				// displayBlanksAs
	NULL,			// xAxisLabel
	$yAxisLabel		// yAxisLabel
);

//	Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('A7');
$chart->setBottomRightPosition('H20');

//	Add the chart to the worksheet
$objWorksheet->addChart($chart);


// Save Excel 2007 file

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setIncludeCharts(TRUE);
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
Et celui qui ne fonctionne pas
$query = Cnx::connectCnx()->query("SELECT year(date_vente) an1,
				SUM(CASE WHEN MONTH(date_vente) = 1 THEN ttc/(1+(tva/100)) ELSE 0 END) Jan,    
				SUM(CASE WHEN MONTH(date_vente) = 2 THEN ttc/(1+(tva/100)) ELSE 0 END) Fev,    
				SUM(CASE WHEN MONTH(date_vente) = 3 THEN ttc/(1+(tva/100)) ELSE 0 END) Mar,
				SUM(CASE WHEN MONTH(date_vente) = 4 THEN ttc/(1+(tva/100)) ELSE 0 END) Avril,
				SUM(CASE WHEN MONTH(date_vente) = 5 THEN ttc/(1+(tva/100)) ELSE 0 END) Mai,
				SUM(CASE WHEN MONTH(date_vente) = 6 THEN ttc/(1+(tva/100)) ELSE 0 END) Juin,
				SUM(CASE WHEN MONTH(date_vente) = 7 THEN ttc/(1+(tva/100)) ELSE 0 END) Juil,
				SUM(CASE WHEN MONTH(date_vente) = 8 THEN ttc/(1+(tva/100)) ELSE 0 END) Aout,
				SUM(CASE WHEN MONTH(date_vente) = 9 THEN ttc/(1+(tva/100)) ELSE 0 END) Sept,
				SUM(CASE WHEN MONTH(date_vente) = 10 THEN ttc/(1+(tva/100)) ELSE 0 END) Oct,
				SUM(CASE WHEN MONTH(date_vente) = 11 THEN ttc/(1+(tva/100)) ELSE 0 END) Nov,
				SUM(CASE WHEN MONTH(date_vente) = 12 THEN ttc/(1+(tva/100)) ELSE 0 END) `Dec`, 
				SUM(ttc/(1+(tva/100))) as Total
				FROM contacts  WHERE id_societe=17 AND YEAR(date_vente) NOT LIKE '0'  GROUP BY an1");

$sheet=array(); // l'array globale
$colonne=array('Annee','Janvier','Fevrier','Mars','Avril','Mai','Juin','Juillet','Aout','Septembre','Octobre','Novembre','Decembre', 'Total'); 
array_push($sheet,$colonne);

while($data = $query->fetch(PDO::FETCH_BOTH)){
$colonne=array();//on réinitialise la ligne
array_push($colonne,$data['an1']);//on rempli chaque colonne de la ligne
array_push($colonne,$data['Jan']);//....
array_push($colonne,$data['Fev']);
array_push($colonne,$data['Mar']);
array_push($colonne,$data['Avril']);
array_push($colonne,$data['Mai']);
array_push($colonne,$data['Juin']);
array_push($colonne,$data['Juil']);
array_push($colonne,$data['Aout']);
array_push($colonne,$data['Sept']);
array_push($colonne,$data['Oct']);
array_push($colonne,$data['Nov']);
array_push($colonne,$data['Dec']);
array_push($colonne,$data['Total']);//... jusqu'ici
array_push($sheet,$colonne);//puis on met la ligne dans notre feuille
}
$finalsheet=array();
foreach($sheet as $value) {
    foreach($value as $k=>$v) {
        $finalsheet[$k][]=$v;
    }
}

//et finalement:
$objPHPExcel = new PHPExcel();
$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet->fromArray($finalsheet);

//	Set the Labels for each data series we want to plot
//		Datatype
//		Cell reference for data
//		Format Code
//		Number of datapoints in series
//		Data values
//		Data Marker
$dataSeriesLabels = array(
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$1', NULL, 1),	
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$2', NULL, 1),	//	janv
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$3', NULL, 1),	//	fev
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$4', NULL, 1),	//	mars
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$5', NULL, 1),	//	avril
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$6', NULL, 1),	//	mai
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$7', NULL, 1),	//	juin
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$8', NULL, 1),	//	juill
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$9', NULL, 1),	//	aout
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$10', NULL, 1),	//	sept
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$11', NULL, 1),	//	oct
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$12', NULL, 1),	//	nov
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$13', NULL, 1),	//	dec
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$A$14', NULL, 1),	//	total
);
//	Set the X-Axis Labels
//		Datatype
//		Cell reference for data
//		Format Code
//		Number of datapoints in series
//		Data values
//		Data Marker
$xAxisTickValues = array(
	new PHPExcel_Chart_DataSeriesValues('String', 'WorkobjWorksheet!$B$1:$C$1', NULL, 2),	//	2012 a 2015
);
//	Set the Data values for each data series we want to plot
//		Datatype
//		Cell reference for data
//		Format Code
//		Number of datapoints in series
//		Data values
//		Data Marker
$dataSeriesValues = array(
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$2:$C$2', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$3:$C$3', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$4:$C$4', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$5:$C$5', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$6:$C$6', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$7:$C$7', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$8:$C$8', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$9:$C$9', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$10:$C$10', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$11:$C$11', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$12:$C$12', NULL, 2),
	new PHPExcel_Chart_DataSeriesValues('Number', 'WorkobjWorksheet!$B$13:$C$13', NULL, 2),
);

//	Build the dataseries
$series = new PHPExcel_Chart_DataSeries(
	PHPExcel_Chart_DataSeries::TYPE_LINECHART,		// plotType
	PHPExcel_Chart_DataSeries::GROUPING_STACKED,	// plotGrouping
	range(0, count($dataSeriesValues)-1),			// plotOrder
	$dataSeriesLabels,								// plotLabel
	$xAxisTickValues,								// plotCategory
	$dataSeriesValues								// plotValues
);

//	Set the series in the plot area
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series));
//	Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_TOPRIGHT, NULL, false);

$title = new PHPExcel_Chart_Title('Test Stacked Line Chart');
$yAxisLabel = new PHPExcel_Chart_Title('Value ($k)');


//	Create the chart
$chart = new PHPExcel_Chart(
	'chart1',		// name
	$title,			// title
	$legend,		// legend
	$plotArea,		// plotArea
	true,			// plotVisibleOnly
	0,				// displayBlanksAs
	NULL,			// xAxisLabel
	$yAxisLabel		// yAxisLabel
);

//	Set the position where the chart should appear in the workobjWorksheet
$chart->setTopLeftPosition('F2');
$chart->setBottomRightPosition('M16');

//	Add the chart to the workobjWorksheet
$objWorksheet->addChart($chart);


// Save Excel 2007 file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setIncludeCharts(TRUE);
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
Je laisse tomber, je vais faire autrement.....
Merci chapt0011 et bonne soirée a tous