Chart.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2014 PHPExcel
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel_Writer_Excel2007
  23. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version 1.8.0, 2014-03-02
  26. */
  27. /**
  28. * PHPExcel_Writer_Excel2007_Chart
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Writer_Excel2007
  32. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. */
  34. class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPart
  35. {
  36. /**
  37. * Write charts to XML format
  38. *
  39. * @param PHPExcel_Chart $pChart
  40. * @return string XML Output
  41. * @throws PHPExcel_Writer_Exception
  42. */
  43. public function writeChart(PHPExcel_Chart $pChart = null)
  44. {
  45. // Create XML writer
  46. $objWriter = null;
  47. if ($this->getParentWriter()->getUseDiskCaching()) {
  48. $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
  49. } else {
  50. $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
  51. }
  52. // Ensure that data series values are up-to-date before we save
  53. $pChart->refresh();
  54. // XML header
  55. $objWriter->startDocument('1.0','UTF-8','yes');
  56. // c:chartSpace
  57. $objWriter->startElement('c:chartSpace');
  58. $objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
  59. $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
  60. $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
  61. $objWriter->startElement('c:date1904');
  62. $objWriter->writeAttribute('val', 0);
  63. $objWriter->endElement();
  64. $objWriter->startElement('c:lang');
  65. $objWriter->writeAttribute('val', "en-GB");
  66. $objWriter->endElement();
  67. $objWriter->startElement('c:roundedCorners');
  68. $objWriter->writeAttribute('val', 0);
  69. $objWriter->endElement();
  70. $this->_writeAlternateContent($objWriter);
  71. $objWriter->startElement('c:chart');
  72. $this->_writeTitle($pChart->getTitle(), $objWriter);
  73. $objWriter->startElement('c:autoTitleDeleted');
  74. $objWriter->writeAttribute('val', 0);
  75. $objWriter->endElement();
  76. $this->_writePlotArea($pChart->getPlotArea(),
  77. $pChart->getXAxisLabel(),
  78. $pChart->getYAxisLabel(),
  79. $objWriter,
  80. $pChart->getWorksheet()
  81. );
  82. $this->_writeLegend($pChart->getLegend(), $objWriter);
  83. $objWriter->startElement('c:plotVisOnly');
  84. $objWriter->writeAttribute('val', 1);
  85. $objWriter->endElement();
  86. $objWriter->startElement('c:dispBlanksAs');
  87. $objWriter->writeAttribute('val', "gap");
  88. $objWriter->endElement();
  89. $objWriter->startElement('c:showDLblsOverMax');
  90. $objWriter->writeAttribute('val', 0);
  91. $objWriter->endElement();
  92. $objWriter->endElement();
  93. $this->_writePrintSettings($objWriter);
  94. $objWriter->endElement();
  95. // Return
  96. return $objWriter->getData();
  97. }
  98. /**
  99. * Write Chart Title
  100. *
  101. * @param PHPExcel_Chart_Title $title
  102. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  103. * @throws PHPExcel_Writer_Exception
  104. */
  105. private function _writeTitle(PHPExcel_Chart_Title $title = null, $objWriter)
  106. {
  107. if (is_null($title)) {
  108. return;
  109. }
  110. $objWriter->startElement('c:title');
  111. $objWriter->startElement('c:tx');
  112. $objWriter->startElement('c:rich');
  113. $objWriter->startElement('a:bodyPr');
  114. $objWriter->endElement();
  115. $objWriter->startElement('a:lstStyle');
  116. $objWriter->endElement();
  117. $objWriter->startElement('a:p');
  118. $caption = $title->getCaption();
  119. if ((is_array($caption)) && (count($caption) > 0))
  120. $caption = $caption[0];
  121. $this->getParentWriter()->getWriterPart('stringtable')->writeRichTextForCharts($objWriter, $caption, 'a');
  122. $objWriter->endElement();
  123. $objWriter->endElement();
  124. $objWriter->endElement();
  125. $layout = $title->getLayout();
  126. $this->_writeLayout($layout, $objWriter);
  127. $objWriter->startElement('c:overlay');
  128. $objWriter->writeAttribute('val', 0);
  129. $objWriter->endElement();
  130. $objWriter->endElement();
  131. }
  132. /**
  133. * Write Chart Legend
  134. *
  135. * @param PHPExcel_Chart_Legend $legend
  136. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  137. * @throws PHPExcel_Writer_Exception
  138. */
  139. private function _writeLegend(PHPExcel_Chart_Legend $legend = null, $objWriter)
  140. {
  141. if (is_null($legend)) {
  142. return;
  143. }
  144. $objWriter->startElement('c:legend');
  145. $objWriter->startElement('c:legendPos');
  146. $objWriter->writeAttribute('val', $legend->getPosition());
  147. $objWriter->endElement();
  148. $layout = $legend->getLayout();
  149. $this->_writeLayout($layout, $objWriter);
  150. $objWriter->startElement('c:overlay');
  151. $objWriter->writeAttribute('val', ($legend->getOverlay()) ? '1' : '0');
  152. $objWriter->endElement();
  153. $objWriter->startElement('c:txPr');
  154. $objWriter->startElement('a:bodyPr');
  155. $objWriter->endElement();
  156. $objWriter->startElement('a:lstStyle');
  157. $objWriter->endElement();
  158. $objWriter->startElement('a:p');
  159. $objWriter->startElement('a:pPr');
  160. $objWriter->writeAttribute('rtl', 0);
  161. $objWriter->startElement('a:defRPr');
  162. $objWriter->endElement();
  163. $objWriter->endElement();
  164. $objWriter->startElement('a:endParaRPr');
  165. $objWriter->writeAttribute('lang', "en-US");
  166. $objWriter->endElement();
  167. $objWriter->endElement();
  168. $objWriter->endElement();
  169. $objWriter->endElement();
  170. }
  171. /**
  172. * Write Chart Plot Area
  173. *
  174. * @param PHPExcel_Chart_PlotArea $plotArea
  175. * @param PHPExcel_Chart_Title $xAxisLabel
  176. * @param PHPExcel_Chart_Title $yAxisLabel
  177. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  178. * @throws PHPExcel_Writer_Exception
  179. */
  180. private function _writePlotArea(PHPExcel_Chart_PlotArea $plotArea,
  181. PHPExcel_Chart_Title $xAxisLabel = NULL,
  182. PHPExcel_Chart_Title $yAxisLabel = NULL,
  183. $objWriter,
  184. PHPExcel_Worksheet $pSheet)
  185. {
  186. if (is_null($plotArea)) {
  187. return;
  188. }
  189. $id1 = $id2 = 0;
  190. $this->_seriesIndex = 0;
  191. $objWriter->startElement('c:plotArea');
  192. $layout = $plotArea->getLayout();
  193. $this->_writeLayout($layout, $objWriter);
  194. $chartTypes = self::_getChartType($plotArea);
  195. $catIsMultiLevelSeries = $valIsMultiLevelSeries = FALSE;
  196. $plotGroupingType = '';
  197. foreach($chartTypes as $chartType) {
  198. $objWriter->startElement('c:'.$chartType);
  199. $groupCount = $plotArea->getPlotGroupCount();
  200. for($i = 0; $i < $groupCount; ++$i) {
  201. $plotGroup = $plotArea->getPlotGroupByIndex($i);
  202. $groupType = $plotGroup->getPlotType();
  203. if ($groupType == $chartType) {
  204. $plotStyle = $plotGroup->getPlotStyle();
  205. if ($groupType === PHPExcel_Chart_DataSeries::TYPE_RADARCHART) {
  206. $objWriter->startElement('c:radarStyle');
  207. $objWriter->writeAttribute('val', $plotStyle );
  208. $objWriter->endElement();
  209. } elseif ($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART) {
  210. $objWriter->startElement('c:scatterStyle');
  211. $objWriter->writeAttribute('val', $plotStyle );
  212. $objWriter->endElement();
  213. }
  214. $this->_writePlotGroup($plotGroup, $chartType, $objWriter, $catIsMultiLevelSeries, $valIsMultiLevelSeries, $plotGroupingType, $pSheet);
  215. }
  216. }
  217. $this->_writeDataLbls($objWriter, $layout);
  218. if ($chartType === PHPExcel_Chart_DataSeries::TYPE_LINECHART) {
  219. // Line only, Line3D can't be smoothed
  220. $objWriter->startElement('c:smooth');
  221. $objWriter->writeAttribute('val', (integer) $plotGroup->getSmoothLine() );
  222. $objWriter->endElement();
  223. } elseif (($chartType === PHPExcel_Chart_DataSeries::TYPE_BARCHART) ||
  224. ($chartType === PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D)) {
  225. $objWriter->startElement('c:gapWidth');
  226. $objWriter->writeAttribute('val', 150 );
  227. $objWriter->endElement();
  228. if ($plotGroupingType == 'percentStacked' ||
  229. $plotGroupingType == 'stacked') {
  230. $objWriter->startElement('c:overlap');
  231. $objWriter->writeAttribute('val', 100 );
  232. $objWriter->endElement();
  233. }
  234. } elseif ($chartType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
  235. $objWriter->startElement('c:bubbleScale');
  236. $objWriter->writeAttribute('val', 25 );
  237. $objWriter->endElement();
  238. $objWriter->startElement('c:showNegBubbles');
  239. $objWriter->writeAttribute('val', 0 );
  240. $objWriter->endElement();
  241. } elseif ($chartType === PHPExcel_Chart_DataSeries::TYPE_STOCKCHART) {
  242. $objWriter->startElement('c:hiLowLines');
  243. $objWriter->endElement();
  244. $objWriter->startElement( 'c:upDownBars' );
  245. $objWriter->startElement( 'c:gapWidth' );
  246. $objWriter->writeAttribute('val', 300);
  247. $objWriter->endElement();
  248. $objWriter->startElement( 'c:upBars' );
  249. $objWriter->endElement();
  250. $objWriter->startElement( 'c:downBars' );
  251. $objWriter->endElement();
  252. $objWriter->endElement();
  253. }
  254. // Generate 2 unique numbers to use for axId values
  255. // $id1 = $id2 = rand(10000000,99999999);
  256. // do {
  257. // $id2 = rand(10000000,99999999);
  258. // } while ($id1 == $id2);
  259. $id1 = '75091328';
  260. $id2 = '75089408';
  261. if (($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART) &&
  262. ($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) &&
  263. ($chartType !== PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
  264. $objWriter->startElement('c:axId');
  265. $objWriter->writeAttribute('val', $id1 );
  266. $objWriter->endElement();
  267. $objWriter->startElement('c:axId');
  268. $objWriter->writeAttribute('val', $id2 );
  269. $objWriter->endElement();
  270. } else {
  271. $objWriter->startElement('c:firstSliceAng');
  272. $objWriter->writeAttribute('val', 0);
  273. $objWriter->endElement();
  274. if ($chartType === PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) {
  275. $objWriter->startElement('c:holeSize');
  276. $objWriter->writeAttribute('val', 50);
  277. $objWriter->endElement();
  278. }
  279. }
  280. $objWriter->endElement();
  281. }
  282. if (($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART) &&
  283. ($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) &&
  284. ($chartType !== PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
  285. if ($chartType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
  286. $this->_writeValAx($objWriter,$plotArea,$xAxisLabel,$chartType,$id1,$id2,$catIsMultiLevelSeries);
  287. } else {
  288. $this->_writeCatAx($objWriter,$plotArea,$xAxisLabel,$chartType,$id1,$id2,$catIsMultiLevelSeries);
  289. }
  290. $this->_writeValAx($objWriter,$plotArea,$yAxisLabel,$chartType,$id1,$id2,$valIsMultiLevelSeries);
  291. }
  292. $objWriter->endElement();
  293. }
  294. /**
  295. * Write Data Labels
  296. *
  297. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  298. * @param PHPExcel_Chart_Layout $chartLayout Chart layout
  299. * @throws PHPExcel_Writer_Exception
  300. */
  301. private function _writeDataLbls($objWriter, $chartLayout)
  302. {
  303. $objWriter->startElement('c:dLbls');
  304. $objWriter->startElement('c:showLegendKey');
  305. $showLegendKey = (empty($chartLayout)) ? 0 : $chartLayout->getShowLegendKey();
  306. $objWriter->writeAttribute('val', ((empty($showLegendKey)) ? 0 : 1) );
  307. $objWriter->endElement();
  308. $objWriter->startElement('c:showVal');
  309. $showVal = (empty($chartLayout)) ? 0 : $chartLayout->getShowVal();
  310. $objWriter->writeAttribute('val', ((empty($showVal)) ? 0 : 1) );
  311. $objWriter->endElement();
  312. $objWriter->startElement('c:showCatName');
  313. $showCatName = (empty($chartLayout)) ? 0 : $chartLayout->getShowCatName();
  314. $objWriter->writeAttribute('val', ((empty($showCatName)) ? 0 : 1) );
  315. $objWriter->endElement();
  316. $objWriter->startElement('c:showSerName');
  317. $showSerName = (empty($chartLayout)) ? 0 : $chartLayout->getShowSerName();
  318. $objWriter->writeAttribute('val', ((empty($showSerName)) ? 0 : 1) );
  319. $objWriter->endElement();
  320. $objWriter->startElement('c:showPercent');
  321. $showPercent = (empty($chartLayout)) ? 0 : $chartLayout->getShowPercent();
  322. $objWriter->writeAttribute('val', ((empty($showPercent)) ? 0 : 1) );
  323. $objWriter->endElement();
  324. $objWriter->startElement('c:showBubbleSize');
  325. $showBubbleSize = (empty($chartLayout)) ? 0 : $chartLayout->getShowBubbleSize();
  326. $objWriter->writeAttribute('val', ((empty($showBubbleSize)) ? 0 : 1) );
  327. $objWriter->endElement();
  328. $objWriter->startElement('c:showLeaderLines');
  329. $showLeaderLines = (empty($chartLayout)) ? 1 : $chartLayout->getShowLeaderLines();
  330. $objWriter->writeAttribute('val', ((empty($showLeaderLines)) ? 0 : 1) );
  331. $objWriter->endElement();
  332. $objWriter->endElement();
  333. }
  334. /**
  335. * Write Category Axis
  336. *
  337. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  338. * @param PHPExcel_Chart_PlotArea $plotArea
  339. * @param PHPExcel_Chart_Title $xAxisLabel
  340. * @param string $groupType Chart type
  341. * @param string $id1
  342. * @param string $id2
  343. * @param boolean $isMultiLevelSeries
  344. * @throws PHPExcel_Writer_Exception
  345. */
  346. private function _writeCatAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $xAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries)
  347. {
  348. $objWriter->startElement('c:catAx');
  349. if ($id1 > 0) {
  350. $objWriter->startElement('c:axId');
  351. $objWriter->writeAttribute('val', $id1);
  352. $objWriter->endElement();
  353. }
  354. $objWriter->startElement('c:scaling');
  355. $objWriter->startElement('c:orientation');
  356. $objWriter->writeAttribute('val', "minMax");
  357. $objWriter->endElement();
  358. $objWriter->endElement();
  359. $objWriter->startElement('c:delete');
  360. $objWriter->writeAttribute('val', 0);
  361. $objWriter->endElement();
  362. $objWriter->startElement('c:axPos');
  363. $objWriter->writeAttribute('val', "b");
  364. $objWriter->endElement();
  365. if (!is_null($xAxisLabel)) {
  366. $objWriter->startElement('c:title');
  367. $objWriter->startElement('c:tx');
  368. $objWriter->startElement('c:rich');
  369. $objWriter->startElement('a:bodyPr');
  370. $objWriter->endElement();
  371. $objWriter->startElement('a:lstStyle');
  372. $objWriter->endElement();
  373. $objWriter->startElement('a:p');
  374. $objWriter->startElement('a:r');
  375. $caption = $xAxisLabel->getCaption();
  376. if (is_array($caption))
  377. $caption = $caption[0];
  378. $objWriter->startElement('a:t');
  379. // $objWriter->writeAttribute('xml:space', 'preserve');
  380. $objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $caption ));
  381. $objWriter->endElement();
  382. $objWriter->endElement();
  383. $objWriter->endElement();
  384. $objWriter->endElement();
  385. $objWriter->endElement();
  386. $layout = $xAxisLabel->getLayout();
  387. $this->_writeLayout($layout, $objWriter);
  388. $objWriter->startElement('c:overlay');
  389. $objWriter->writeAttribute('val', 0);
  390. $objWriter->endElement();
  391. $objWriter->endElement();
  392. }
  393. $objWriter->startElement('c:numFmt');
  394. $objWriter->writeAttribute('formatCode', "General");
  395. $objWriter->writeAttribute('sourceLinked', 1);
  396. $objWriter->endElement();
  397. $objWriter->startElement('c:majorTickMark');
  398. $objWriter->writeAttribute('val', "out");
  399. $objWriter->endElement();
  400. $objWriter->startElement('c:minorTickMark');
  401. $objWriter->writeAttribute('val', "none");
  402. $objWriter->endElement();
  403. $objWriter->startElement('c:tickLblPos');
  404. $objWriter->writeAttribute('val', "nextTo");
  405. $objWriter->endElement();
  406. if ($id2 > 0) {
  407. $objWriter->startElement('c:crossAx');
  408. $objWriter->writeAttribute('val', $id2);
  409. $objWriter->endElement();
  410. $objWriter->startElement('c:crosses');
  411. $objWriter->writeAttribute('val', "autoZero");
  412. $objWriter->endElement();
  413. }
  414. $objWriter->startElement('c:auto');
  415. $objWriter->writeAttribute('val', 1);
  416. $objWriter->endElement();
  417. $objWriter->startElement('c:lblAlgn');
  418. $objWriter->writeAttribute('val', "ctr");
  419. $objWriter->endElement();
  420. $objWriter->startElement('c:lblOffset');
  421. $objWriter->writeAttribute('val', 100);
  422. $objWriter->endElement();
  423. if ($isMultiLevelSeries) {
  424. $objWriter->startElement('c:noMultiLvlLbl');
  425. $objWriter->writeAttribute('val', 0);
  426. $objWriter->endElement();
  427. }
  428. $objWriter->endElement();
  429. }
  430. /**
  431. * Write Value Axis
  432. *
  433. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  434. * @param PHPExcel_Chart_PlotArea $plotArea
  435. * @param PHPExcel_Chart_Title $yAxisLabel
  436. * @param string $groupType Chart type
  437. * @param string $id1
  438. * @param string $id2
  439. * @param boolean $isMultiLevelSeries
  440. * @throws PHPExcel_Writer_Exception
  441. */
  442. private function _writeValAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries)
  443. {
  444. $objWriter->startElement('c:valAx');
  445. if ($id2 > 0) {
  446. $objWriter->startElement('c:axId');
  447. $objWriter->writeAttribute('val', $id2);
  448. $objWriter->endElement();
  449. }
  450. $objWriter->startElement('c:scaling');
  451. $objWriter->startElement('c:orientation');
  452. $objWriter->writeAttribute('val', "minMax");
  453. $objWriter->endElement();
  454. $objWriter->endElement();
  455. $objWriter->startElement('c:delete');
  456. $objWriter->writeAttribute('val', 0);
  457. $objWriter->endElement();
  458. $objWriter->startElement('c:axPos');
  459. $objWriter->writeAttribute('val', "l");
  460. $objWriter->endElement();
  461. $objWriter->startElement('c:majorGridlines');
  462. $objWriter->endElement();
  463. if (!is_null($yAxisLabel)) {
  464. $objWriter->startElement('c:title');
  465. $objWriter->startElement('c:tx');
  466. $objWriter->startElement('c:rich');
  467. $objWriter->startElement('a:bodyPr');
  468. $objWriter->endElement();
  469. $objWriter->startElement('a:lstStyle');
  470. $objWriter->endElement();
  471. $objWriter->startElement('a:p');
  472. $objWriter->startElement('a:r');
  473. $caption = $yAxisLabel->getCaption();
  474. if (is_array($caption))
  475. $caption = $caption[0];
  476. $objWriter->startElement('a:t');
  477. // $objWriter->writeAttribute('xml:space', 'preserve');
  478. $objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $caption ));
  479. $objWriter->endElement();
  480. $objWriter->endElement();
  481. $objWriter->endElement();
  482. $objWriter->endElement();
  483. $objWriter->endElement();
  484. if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
  485. $layout = $yAxisLabel->getLayout();
  486. $this->_writeLayout($layout, $objWriter);
  487. }
  488. $objWriter->startElement('c:overlay');
  489. $objWriter->writeAttribute('val', 0);
  490. $objWriter->endElement();
  491. $objWriter->endElement();
  492. }
  493. $objWriter->startElement('c:numFmt');
  494. $objWriter->writeAttribute('formatCode', "General");
  495. $objWriter->writeAttribute('sourceLinked', 1);
  496. $objWriter->endElement();
  497. $objWriter->startElement('c:majorTickMark');
  498. $objWriter->writeAttribute('val', "out");
  499. $objWriter->endElement();
  500. $objWriter->startElement('c:minorTickMark');
  501. $objWriter->writeAttribute('val', "none");
  502. $objWriter->endElement();
  503. $objWriter->startElement('c:tickLblPos');
  504. $objWriter->writeAttribute('val', "nextTo");
  505. $objWriter->endElement();
  506. if ($id1 > 0) {
  507. $objWriter->startElement('c:crossAx');
  508. $objWriter->writeAttribute('val', $id2);
  509. $objWriter->endElement();
  510. $objWriter->startElement('c:crosses');
  511. $objWriter->writeAttribute('val', "autoZero");
  512. $objWriter->endElement();
  513. $objWriter->startElement('c:crossBetween');
  514. $objWriter->writeAttribute('val', "midCat");
  515. $objWriter->endElement();
  516. }
  517. if ($isMultiLevelSeries) {
  518. if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
  519. $objWriter->startElement('c:noMultiLvlLbl');
  520. $objWriter->writeAttribute('val', 0);
  521. $objWriter->endElement();
  522. }
  523. }
  524. $objWriter->endElement();
  525. }
  526. /**
  527. * Get the data series type(s) for a chart plot series
  528. *
  529. * @param PHPExcel_Chart_PlotArea $plotArea
  530. * @return string|array
  531. * @throws PHPExcel_Writer_Exception
  532. */
  533. private static function _getChartType($plotArea)
  534. {
  535. $groupCount = $plotArea->getPlotGroupCount();
  536. if ($groupCount == 1) {
  537. $chartType = array($plotArea->getPlotGroupByIndex(0)->getPlotType());
  538. } else {
  539. $chartTypes = array();
  540. for($i = 0; $i < $groupCount; ++$i) {
  541. $chartTypes[] = $plotArea->getPlotGroupByIndex($i)->getPlotType();
  542. }
  543. $chartType = array_unique($chartTypes);
  544. if (count($chartTypes) == 0) {
  545. throw new PHPExcel_Writer_Exception('Chart is not yet implemented');
  546. }
  547. }
  548. return $chartType;
  549. }
  550. /**
  551. * Write Plot Group (series of related plots)
  552. *
  553. * @param PHPExcel_Chart_DataSeries $plotGroup
  554. * @param string $groupType Type of plot for dataseries
  555. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  556. * @param boolean &$catIsMultiLevelSeries Is category a multi-series category
  557. * @param boolean &$valIsMultiLevelSeries Is value set a multi-series set
  558. * @param string &$plotGroupingType Type of grouping for multi-series values
  559. * @param PHPExcel_Worksheet $pSheet
  560. * @throws PHPExcel_Writer_Exception
  561. */
  562. private function _writePlotGroup( $plotGroup,
  563. $groupType,
  564. $objWriter,
  565. &$catIsMultiLevelSeries,
  566. &$valIsMultiLevelSeries,
  567. &$plotGroupingType,
  568. PHPExcel_Worksheet $pSheet
  569. )
  570. {
  571. if (is_null($plotGroup)) {
  572. return;
  573. }
  574. if (($groupType == PHPExcel_Chart_DataSeries::TYPE_BARCHART) ||
  575. ($groupType == PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D)) {
  576. $objWriter->startElement('c:barDir');
  577. $objWriter->writeAttribute('val', $plotGroup->getPlotDirection());
  578. $objWriter->endElement();
  579. }
  580. if (!is_null($plotGroup->getPlotGrouping())) {
  581. $plotGroupingType = $plotGroup->getPlotGrouping();
  582. $objWriter->startElement('c:grouping');
  583. $objWriter->writeAttribute('val', $plotGroupingType);
  584. $objWriter->endElement();
  585. }
  586. // Get these details before the loop, because we can use the count to check for varyColors
  587. $plotSeriesOrder = $plotGroup->getPlotOrder();
  588. $plotSeriesCount = count($plotSeriesOrder);
  589. if (($groupType !== PHPExcel_Chart_DataSeries::TYPE_RADARCHART) &&
  590. ($groupType !== PHPExcel_Chart_DataSeries::TYPE_STOCKCHART)) {
  591. if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_LINECHART) {
  592. if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) ||
  593. ($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) ||
  594. ($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) ||
  595. ($plotSeriesCount > 1)) {
  596. $objWriter->startElement('c:varyColors');
  597. $objWriter->writeAttribute('val', 1);
  598. $objWriter->endElement();
  599. } else {
  600. $objWriter->startElement('c:varyColors');
  601. $objWriter->writeAttribute('val', 0);
  602. $objWriter->endElement();
  603. }
  604. }
  605. }
  606. foreach($plotSeriesOrder as $plotSeriesIdx => $plotSeriesRef) {
  607. $objWriter->startElement('c:ser');
  608. $objWriter->startElement('c:idx');
  609. $objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesIdx);
  610. $objWriter->endElement();
  611. $objWriter->startElement('c:order');
  612. $objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesRef);
  613. $objWriter->endElement();
  614. if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) ||
  615. ($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) ||
  616. ($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
  617. $objWriter->startElement('c:dPt');
  618. $objWriter->startElement('c:idx');
  619. $objWriter->writeAttribute('val', 3);
  620. $objWriter->endElement();
  621. $objWriter->startElement('c:bubble3D');
  622. $objWriter->writeAttribute('val', 0);
  623. $objWriter->endElement();
  624. $objWriter->startElement('c:spPr');
  625. $objWriter->startElement('a:solidFill');
  626. $objWriter->startElement('a:srgbClr');
  627. $objWriter->writeAttribute('val', 'FF9900');
  628. $objWriter->endElement();
  629. $objWriter->endElement();
  630. $objWriter->endElement();
  631. $objWriter->endElement();
  632. }
  633. // Labels
  634. $plotSeriesLabel = $plotGroup->getPlotLabelByIndex($plotSeriesRef);
  635. if ($plotSeriesLabel && ($plotSeriesLabel->getPointCount() > 0)) {
  636. $objWriter->startElement('c:tx');
  637. $objWriter->startElement('c:strRef');
  638. $this->_writePlotSeriesLabel($plotSeriesLabel, $objWriter);
  639. $objWriter->endElement();
  640. $objWriter->endElement();
  641. }
  642. // Formatting for the points
  643. if (($groupType == PHPExcel_Chart_DataSeries::TYPE_LINECHART) ||
  644. ($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART)) {
  645. $objWriter->startElement('c:spPr');
  646. $objWriter->startElement('a:ln');
  647. $objWriter->writeAttribute('w', 12700);
  648. if ($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART) {
  649. $objWriter->startElement('a:noFill');
  650. $objWriter->endElement();
  651. }
  652. $objWriter->endElement();
  653. $objWriter->endElement();
  654. }
  655. $plotSeriesValues = $plotGroup->getPlotValuesByIndex($plotSeriesRef);
  656. if ($plotSeriesValues) {
  657. $plotSeriesMarker = $plotSeriesValues->getPointMarker();
  658. if ($plotSeriesMarker) {
  659. $objWriter->startElement('c:marker');
  660. $objWriter->startElement('c:symbol');
  661. $objWriter->writeAttribute('val', $plotSeriesMarker);
  662. $objWriter->endElement();
  663. if ($plotSeriesMarker !== 'none') {
  664. $objWriter->startElement('c:size');
  665. $objWriter->writeAttribute('val', 3);
  666. $objWriter->endElement();
  667. }
  668. $objWriter->endElement();
  669. }
  670. }
  671. if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BARCHART) ||
  672. ($groupType === PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D) ||
  673. ($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART)) {
  674. $objWriter->startElement('c:invertIfNegative');
  675. $objWriter->writeAttribute('val', 0);
  676. $objWriter->endElement();
  677. }
  678. // Category Labels
  679. $plotSeriesCategory = $plotGroup->getPlotCategoryByIndex($plotSeriesRef);
  680. if ($plotSeriesCategory && ($plotSeriesCategory->getPointCount() > 0)) {
  681. $catIsMultiLevelSeries = $catIsMultiLevelSeries || $plotSeriesCategory->isMultiLevelSeries();
  682. if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) ||
  683. ($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) ||
  684. ($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
  685. if (!is_null($plotGroup->getPlotStyle())) {
  686. $plotStyle = $plotGroup->getPlotStyle();
  687. if ($plotStyle) {
  688. $objWriter->startElement('c:explosion');
  689. $objWriter->writeAttribute('val', 25);
  690. $objWriter->endElement();
  691. }
  692. }
  693. }
  694. if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) ||
  695. ($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART)) {
  696. $objWriter->startElement('c:xVal');
  697. } else {
  698. $objWriter->startElement('c:cat');
  699. }
  700. $this->_writePlotSeriesValues($plotSeriesCategory, $objWriter, $groupType, 'str', $pSheet);
  701. $objWriter->endElement();
  702. }
  703. // Values
  704. if ($plotSeriesValues) {
  705. $valIsMultiLevelSeries = $valIsMultiLevelSeries || $plotSeriesValues->isMultiLevelSeries();
  706. if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) ||
  707. ($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART)) {
  708. $objWriter->startElement('c:yVal');
  709. } else {
  710. $objWriter->startElement('c:val');
  711. }
  712. $this->_writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, 'num', $pSheet);
  713. $objWriter->endElement();
  714. }
  715. if ($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
  716. $this->_writeBubbles($plotSeriesValues, $objWriter, $pSheet);
  717. }
  718. $objWriter->endElement();
  719. }
  720. $this->_seriesIndex += $plotSeriesIdx + 1;
  721. }
  722. /**
  723. * Write Plot Series Label
  724. *
  725. * @param PHPExcel_Chart_DataSeriesValues $plotSeriesLabel
  726. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  727. * @throws PHPExcel_Writer_Exception
  728. */
  729. private function _writePlotSeriesLabel($plotSeriesLabel, $objWriter)
  730. {
  731. if (is_null($plotSeriesLabel)) {
  732. return;
  733. }
  734. $objWriter->startElement('c:f');
  735. $objWriter->writeRawData($plotSeriesLabel->getDataSource());
  736. $objWriter->endElement();
  737. $objWriter->startElement('c:strCache');
  738. $objWriter->startElement('c:ptCount');
  739. $objWriter->writeAttribute('val', $plotSeriesLabel->getPointCount() );
  740. $objWriter->endElement();
  741. foreach($plotSeriesLabel->getDataValues() as $plotLabelKey => $plotLabelValue) {
  742. $objWriter->startElement('c:pt');
  743. $objWriter->writeAttribute('idx', $plotLabelKey );
  744. $objWriter->startElement('c:v');
  745. $objWriter->writeRawData( $plotLabelValue );
  746. $objWriter->endElement();
  747. $objWriter->endElement();
  748. }
  749. $objWriter->endElement();
  750. }
  751. /**
  752. * Write Plot Series Values
  753. *
  754. * @param PHPExcel_Chart_DataSeriesValues $plotSeriesValues
  755. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  756. * @param string $groupType Type of plot for dataseries
  757. * @param string $dataType Datatype of series values
  758. * @param PHPExcel_Worksheet $pSheet
  759. * @throws PHPExcel_Writer_Exception
  760. */
  761. private function _writePlotSeriesValues( $plotSeriesValues,
  762. $objWriter,
  763. $groupType,
  764. $dataType='str',
  765. PHPExcel_Worksheet $pSheet
  766. )
  767. {
  768. if (is_null($plotSeriesValues)) {
  769. return;
  770. }
  771. if ($plotSeriesValues->isMultiLevelSeries()) {
  772. $levelCount = $plotSeriesValues->multiLevelCount();
  773. $objWriter->startElement('c:multiLvlStrRef');
  774. $objWriter->startElement('c:f');
  775. $objWriter->writeRawData( $plotSeriesValues->getDataSource() );
  776. $objWriter->endElement();
  777. $objWriter->startElement('c:multiLvlStrCache');
  778. $objWriter->startElement('c:ptCount');
  779. $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount() );
  780. $objWriter->endElement();
  781. for ($level = 0; $level < $levelCount; ++$level) {
  782. $objWriter->startElement('c:lvl');
  783. foreach($plotSeriesValues->getDataValues() as $plotSeriesKey => $plotSeriesValue) {
  784. if (isset($plotSeriesValue[$level])) {
  785. $objWriter->startElement('c:pt');
  786. $objWriter->writeAttribute('idx', $plotSeriesKey );
  787. $objWriter->startElement('c:v');
  788. $objWriter->writeRawData( $plotSeriesValue[$level] );
  789. $objWriter->endElement();
  790. $objWriter->endElement();
  791. }
  792. }
  793. $objWriter->endElement();
  794. }
  795. $objWriter->endElement();
  796. $objWriter->endElement();
  797. } else {
  798. $objWriter->startElement('c:'.$dataType.'Ref');
  799. $objWriter->startElement('c:f');
  800. $objWriter->writeRawData( $plotSeriesValues->getDataSource() );
  801. $objWriter->endElement();
  802. $objWriter->startElement('c:'.$dataType.'Cache');
  803. if (($groupType != PHPExcel_Chart_DataSeries::TYPE_PIECHART) &&
  804. ($groupType != PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) &&
  805. ($groupType != PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
  806. if (($plotSeriesValues->getFormatCode() !== NULL) &&
  807. ($plotSeriesValues->getFormatCode() !== '')) {
  808. $objWriter->startElement('c:formatCode');
  809. $objWriter->writeRawData( $plotSeriesValues->getFormatCode() );
  810. $objWriter->endElement();
  811. }
  812. }
  813. $objWriter->startElement('c:ptCount');
  814. $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount() );
  815. $objWriter->endElement();
  816. $dataValues = $plotSeriesValues->getDataValues();
  817. if (!empty($dataValues)) {
  818. if (is_array($dataValues)) {
  819. foreach($dataValues as $plotSeriesKey => $plotSeriesValue) {
  820. $objWriter->startElement('c:pt');
  821. $objWriter->writeAttribute('idx', $plotSeriesKey );
  822. $objWriter->startElement('c:v');
  823. $objWriter->writeRawData( $plotSeriesValue );
  824. $objWriter->endElement();
  825. $objWriter->endElement();
  826. }
  827. }
  828. }
  829. $objWriter->endElement();
  830. $objWriter->endElement();
  831. }
  832. }
  833. /**
  834. * Write Bubble Chart Details
  835. *
  836. * @param PHPExcel_Chart_DataSeriesValues $plotSeriesValues
  837. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  838. * @throws PHPExcel_Writer_Exception
  839. */
  840. private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet)
  841. {
  842. if (is_null($plotSeriesValues)) {
  843. return;
  844. }
  845. $objWriter->startElement('c:bubbleSize');
  846. $objWriter->startElement('c:numLit');
  847. $objWriter->startElement('c:formatCode');
  848. $objWriter->writeRawData( 'General' );
  849. $objWriter->endElement();
  850. $objWriter->startElement('c:ptCount');
  851. $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount() );
  852. $objWriter->endElement();
  853. $dataValues = $plotSeriesValues->getDataValues();
  854. if (!empty($dataValues)) {
  855. if (is_array($dataValues)) {
  856. foreach($dataValues as $plotSeriesKey => $plotSeriesValue) {
  857. $objWriter->startElement('c:pt');
  858. $objWriter->writeAttribute('idx', $plotSeriesKey );
  859. $objWriter->startElement('c:v');
  860. $objWriter->writeRawData( 1 );
  861. $objWriter->endElement();
  862. $objWriter->endElement();
  863. }
  864. }
  865. }
  866. $objWriter->endElement();
  867. $objWriter->endElement();
  868. $objWriter->startElement('c:bubble3D');
  869. $objWriter->writeAttribute('val', 0 );
  870. $objWriter->endElement();
  871. }
  872. /**
  873. * Write Layout
  874. *
  875. * @param PHPExcel_Chart_Layout $layout
  876. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  877. * @throws PHPExcel_Writer_Exception
  878. */
  879. private function _writeLayout(PHPExcel_Chart_Layout $layout = NULL, $objWriter)
  880. {
  881. $objWriter->startElement('c:layout');
  882. if (!is_null($layout)) {
  883. $objWriter->startElement('c:manualLayout');
  884. $layoutTarget = $layout->getLayoutTarget();
  885. if (!is_null($layoutTarget)) {
  886. $objWriter->startElement('c:layoutTarget');
  887. $objWriter->writeAttribute('val', $layoutTarget);
  888. $objWriter->endElement();
  889. }
  890. $xMode = $layout->getXMode();
  891. if (!is_null($xMode)) {
  892. $objWriter->startElement('c:xMode');
  893. $objWriter->writeAttribute('val', $xMode);
  894. $objWriter->endElement();
  895. }
  896. $yMode = $layout->getYMode();
  897. if (!is_null($yMode)) {
  898. $objWriter->startElement('c:yMode');
  899. $objWriter->writeAttribute('val', $yMode);
  900. $objWriter->endElement();
  901. }
  902. $x = $layout->getXPosition();
  903. if (!is_null($x)) {
  904. $objWriter->startElement('c:x');
  905. $objWriter->writeAttribute('val', $x);
  906. $objWriter->endElement();
  907. }
  908. $y = $layout->getYPosition();
  909. if (!is_null($y)) {
  910. $objWriter->startElement('c:y');
  911. $objWriter->writeAttribute('val', $y);
  912. $objWriter->endElement();
  913. }
  914. $w = $layout->getWidth();
  915. if (!is_null($w)) {
  916. $objWriter->startElement('c:w');
  917. $objWriter->writeAttribute('val', $w);
  918. $objWriter->endElement();
  919. }
  920. $h = $layout->getHeight();
  921. if (!is_null($h)) {
  922. $objWriter->startElement('c:h');
  923. $objWriter->writeAttribute('val', $h);
  924. $objWriter->endElement();
  925. }
  926. $objWriter->endElement();
  927. }
  928. $objWriter->endElement();
  929. }
  930. /**
  931. * Write Alternate Content block
  932. *
  933. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  934. * @throws PHPExcel_Writer_Exception
  935. */
  936. private function _writeAlternateContent($objWriter)
  937. {
  938. $objWriter->startElement('mc:AlternateContent');
  939. $objWriter->writeAttribute('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
  940. $objWriter->startElement('mc:Choice');
  941. $objWriter->writeAttribute('xmlns:c14', 'http://schemas.microsoft.com/office/drawing/2007/8/2/chart');
  942. $objWriter->writeAttribute('Requires', 'c14');
  943. $objWriter->startElement('c14:style');
  944. $objWriter->writeAttribute('val', '102');
  945. $objWriter->endElement();
  946. $objWriter->endElement();
  947. $objWriter->startElement('mc:Fallback');
  948. $objWriter->startElement('c:style');
  949. $objWriter->writeAttribute('val', '2');
  950. $objWriter->endElement();
  951. $objWriter->endElement();
  952. $objWriter->endElement();
  953. }
  954. /**
  955. * Write Printer Settings
  956. *
  957. * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
  958. * @throws PHPExcel_Writer_Exception
  959. */
  960. private function _writePrintSettings($objWriter)
  961. {
  962. $objWriter->startElement('c:printSettings');
  963. $objWriter->startElement('c:headerFooter');
  964. $objWriter->endElement();
  965. $objWriter->startElement('c:pageMargins');
  966. $objWriter->writeAttribute('footer', 0.3);
  967. $objWriter->writeAttribute('header', 0.3);
  968. $objWriter->writeAttribute('r', 0.7);
  969. $objWriter->writeAttribute('l', 0.7);
  970. $objWriter->writeAttribute('t', 0.75);
  971. $objWriter->writeAttribute('b', 0.75);
  972. $objWriter->endElement();
  973. $objWriter->startElement('c:pageSetup');
  974. $objWriter->writeAttribute('orientation', "portrait");
  975. $objWriter->endElement();
  976. $objWriter->endElement();
  977. }
  978. }