0
0

05featuredemo.inc.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2015 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
  23. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. /** Error reporting */
  28. error_reporting(E_ALL);
  29. /** Include PHPExcel */
  30. require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
  31. // Create new PHPExcel object
  32. echo date('H:i:s') , " Create new PHPExcel object" , EOL;
  33. $objPHPExcel = new PHPExcel();
  34. // Set document properties
  35. echo date('H:i:s') , " Set document properties" , EOL;
  36. $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
  37. ->setLastModifiedBy("Maarten Balliauw")
  38. ->setTitle("Office 2007 XLSX Test Document")
  39. ->setSubject("Office 2007 XLSX Test Document")
  40. ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
  41. ->setKeywords("office 2007 openxml php")
  42. ->setCategory("Test result file");
  43. // Create a first sheet, representing sales data
  44. echo date('H:i:s') , " Add some data" , EOL;
  45. $objPHPExcel->setActiveSheetIndex(0);
  46. $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Invoice');
  47. $objPHPExcel->getActiveSheet()->setCellValue('D1', PHPExcel_Shared_Date::PHPToExcel( gmmktime(0,0,0,date('m'),date('d'),date('Y')) ));
  48. $objPHPExcel->getActiveSheet()->getStyle('D1')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15);
  49. $objPHPExcel->getActiveSheet()->setCellValue('E1', '#12566');
  50. $objPHPExcel->getActiveSheet()->setCellValue('A3', 'Product Id');
  51. $objPHPExcel->getActiveSheet()->setCellValue('B3', 'Description');
  52. $objPHPExcel->getActiveSheet()->setCellValue('C3', 'Price');
  53. $objPHPExcel->getActiveSheet()->setCellValue('D3', 'Amount');
  54. $objPHPExcel->getActiveSheet()->setCellValue('E3', 'Total');
  55. $objPHPExcel->getActiveSheet()->setCellValue('A4', '1001');
  56. $objPHPExcel->getActiveSheet()->setCellValue('B4', 'PHP for dummies');
  57. $objPHPExcel->getActiveSheet()->setCellValue('C4', '20');
  58. $objPHPExcel->getActiveSheet()->setCellValue('D4', '1');
  59. $objPHPExcel->getActiveSheet()->setCellValue('E4', '=IF(D4<>"",C4*D4,"")');
  60. $objPHPExcel->getActiveSheet()->setCellValue('A5', '1012');
  61. $objPHPExcel->getActiveSheet()->setCellValue('B5', 'OpenXML for dummies');
  62. $objPHPExcel->getActiveSheet()->setCellValue('C5', '22');
  63. $objPHPExcel->getActiveSheet()->setCellValue('D5', '2');
  64. $objPHPExcel->getActiveSheet()->setCellValue('E5', '=IF(D5<>"",C5*D5,"")');
  65. $objPHPExcel->getActiveSheet()->setCellValue('E6', '=IF(D6<>"",C6*D6,"")');
  66. $objPHPExcel->getActiveSheet()->setCellValue('E7', '=IF(D7<>"",C7*D7,"")');
  67. $objPHPExcel->getActiveSheet()->setCellValue('E8', '=IF(D8<>"",C8*D8,"")');
  68. $objPHPExcel->getActiveSheet()->setCellValue('E9', '=IF(D9<>"",C9*D9,"")');
  69. $objPHPExcel->getActiveSheet()->setCellValue('D11', 'Total excl.:');
  70. $objPHPExcel->getActiveSheet()->setCellValue('E11', '=SUM(E4:E9)');
  71. $objPHPExcel->getActiveSheet()->setCellValue('D12', 'VAT:');
  72. $objPHPExcel->getActiveSheet()->setCellValue('E12', '=E11*0.21');
  73. $objPHPExcel->getActiveSheet()->setCellValue('D13', 'Total incl.:');
  74. $objPHPExcel->getActiveSheet()->setCellValue('E13', '=E11+E12');
  75. // Add comment
  76. echo date('H:i:s') , " Add comments" , EOL;
  77. $objPHPExcel->getActiveSheet()->getComment('E11')->setAuthor('PHPExcel');
  78. $objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('PHPExcel:');
  79. $objCommentRichText->getFont()->setBold(true);
  80. $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun("\r\n");
  81. $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('Total amount on the current invoice, excluding VAT.');
  82. $objPHPExcel->getActiveSheet()->getComment('E12')->setAuthor('PHPExcel');
  83. $objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E12')->getText()->createTextRun('PHPExcel:');
  84. $objCommentRichText->getFont()->setBold(true);
  85. $objPHPExcel->getActiveSheet()->getComment('E12')->getText()->createTextRun("\r\n");
  86. $objPHPExcel->getActiveSheet()->getComment('E12')->getText()->createTextRun('Total amount of VAT on the current invoice.');
  87. $objPHPExcel->getActiveSheet()->getComment('E13')->setAuthor('PHPExcel');
  88. $objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E13')->getText()->createTextRun('PHPExcel:');
  89. $objCommentRichText->getFont()->setBold(true);
  90. $objPHPExcel->getActiveSheet()->getComment('E13')->getText()->createTextRun("\r\n");
  91. $objPHPExcel->getActiveSheet()->getComment('E13')->getText()->createTextRun('Total amount on the current invoice, including VAT.');
  92. $objPHPExcel->getActiveSheet()->getComment('E13')->setWidth('100pt');
  93. $objPHPExcel->getActiveSheet()->getComment('E13')->setHeight('100pt');
  94. $objPHPExcel->getActiveSheet()->getComment('E13')->setMarginLeft('150pt');
  95. $objPHPExcel->getActiveSheet()->getComment('E13')->getFillColor()->setRGB('EEEEEE');
  96. // Add rich-text string
  97. echo date('H:i:s') , " Add rich-text string" , EOL;
  98. $objRichText = new PHPExcel_RichText();
  99. $objRichText->createText('This invoice is ');
  100. $objPayable = $objRichText->createTextRun('payable within thirty days after the end of the month');
  101. $objPayable->getFont()->setBold(true);
  102. $objPayable->getFont()->setItalic(true);
  103. $objPayable->getFont()->setColor( new PHPExcel_Style_Color( PHPExcel_Style_Color::COLOR_DARKGREEN ) );
  104. $objRichText->createText(', unless specified otherwise on the invoice.');
  105. $objPHPExcel->getActiveSheet()->getCell('A18')->setValue($objRichText);
  106. // Merge cells
  107. echo date('H:i:s') , " Merge cells" , EOL;
  108. $objPHPExcel->getActiveSheet()->mergeCells('A18:E22');
  109. $objPHPExcel->getActiveSheet()->mergeCells('A28:B28'); // Just to test...
  110. $objPHPExcel->getActiveSheet()->unmergeCells('A28:B28'); // Just to test...
  111. // Protect cells
  112. echo date('H:i:s') , " Protect cells" , EOL;
  113. $objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // Needs to be set to true in order to enable any worksheet protection!
  114. $objPHPExcel->getActiveSheet()->protectCells('A3:E13', 'PHPExcel');
  115. // Set cell number formats
  116. echo date('H:i:s') , " Set cell number formats" , EOL;
  117. $objPHPExcel->getActiveSheet()->getStyle('E4:E13')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
  118. // Set column widths
  119. echo date('H:i:s') , " Set column widths" , EOL;
  120. $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
  121. $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(12);
  122. $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(12);
  123. // Set fonts
  124. echo date('H:i:s') , " Set fonts" , EOL;
  125. $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setName('Candara');
  126. $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setSize(20);
  127. $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true);
  128. $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
  129. $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE);
  130. $objPHPExcel->getActiveSheet()->getStyle('D1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE);
  131. $objPHPExcel->getActiveSheet()->getStyle('E1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE);
  132. $objPHPExcel->getActiveSheet()->getStyle('D13')->getFont()->setBold(true);
  133. $objPHPExcel->getActiveSheet()->getStyle('E13')->getFont()->setBold(true);
  134. // Set alignments
  135. echo date('H:i:s') , " Set alignments" , EOL;
  136. $objPHPExcel->getActiveSheet()->getStyle('D11')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  137. $objPHPExcel->getActiveSheet()->getStyle('D12')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  138. $objPHPExcel->getActiveSheet()->getStyle('D13')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  139. $objPHPExcel->getActiveSheet()->getStyle('A18')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY);
  140. $objPHPExcel->getActiveSheet()->getStyle('A18')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
  141. $objPHPExcel->getActiveSheet()->getStyle('B5')->getAlignment()->setShrinkToFit(true);
  142. // Set thin black border outline around column
  143. echo date('H:i:s') , " Set thin black border outline around column" , EOL;
  144. $styleThinBlackBorderOutline = array(
  145. 'borders' => array(
  146. 'outline' => array(
  147. 'style' => PHPExcel_Style_Border::BORDER_THIN,
  148. 'color' => array('argb' => 'FF000000'),
  149. ),
  150. ),
  151. );
  152. $objPHPExcel->getActiveSheet()->getStyle('A4:E10')->applyFromArray($styleThinBlackBorderOutline);
  153. // Set thick brown border outline around "Total"
  154. echo date('H:i:s') , " Set thick brown border outline around Total" , EOL;
  155. $styleThickBrownBorderOutline = array(
  156. 'borders' => array(
  157. 'outline' => array(
  158. 'style' => PHPExcel_Style_Border::BORDER_THICK,
  159. 'color' => array('argb' => 'FF993300'),
  160. ),
  161. ),
  162. );
  163. $objPHPExcel->getActiveSheet()->getStyle('D13:E13')->applyFromArray($styleThickBrownBorderOutline);
  164. // Set fills
  165. echo date('H:i:s') , " Set fills" , EOL;
  166. $objPHPExcel->getActiveSheet()->getStyle('A1:E1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
  167. $objPHPExcel->getActiveSheet()->getStyle('A1:E1')->getFill()->getStartColor()->setARGB('FF808080');
  168. // Set style for header row using alternative method
  169. echo date('H:i:s') , " Set style for header row using alternative method" , EOL;
  170. $objPHPExcel->getActiveSheet()->getStyle('A3:E3')->applyFromArray(
  171. array(
  172. 'font' => array(
  173. 'bold' => true
  174. ),
  175. 'alignment' => array(
  176. 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_RIGHT,
  177. ),
  178. 'borders' => array(
  179. 'top' => array(
  180. 'style' => PHPExcel_Style_Border::BORDER_THIN
  181. )
  182. ),
  183. 'fill' => array(
  184. 'type' => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR,
  185. 'rotation' => 90,
  186. 'startcolor' => array(
  187. 'argb' => 'FFA0A0A0'
  188. ),
  189. 'endcolor' => array(
  190. 'argb' => 'FFFFFFFF'
  191. )
  192. )
  193. )
  194. );
  195. $objPHPExcel->getActiveSheet()->getStyle('A3')->applyFromArray(
  196. array(
  197. 'alignment' => array(
  198. 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
  199. ),
  200. 'borders' => array(
  201. 'left' => array(
  202. 'style' => PHPExcel_Style_Border::BORDER_THIN
  203. )
  204. )
  205. )
  206. );
  207. $objPHPExcel->getActiveSheet()->getStyle('B3')->applyFromArray(
  208. array(
  209. 'alignment' => array(
  210. 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
  211. )
  212. )
  213. );
  214. $objPHPExcel->getActiveSheet()->getStyle('E3')->applyFromArray(
  215. array(
  216. 'borders' => array(
  217. 'right' => array(
  218. 'style' => PHPExcel_Style_Border::BORDER_THIN
  219. )
  220. )
  221. )
  222. );
  223. // Unprotect a cell
  224. echo date('H:i:s') , " Unprotect a cell" , EOL;
  225. $objPHPExcel->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
  226. // Add a hyperlink to the sheet
  227. echo date('H:i:s') , " Add a hyperlink to an external website" , EOL;
  228. $objPHPExcel->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net');
  229. $objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net');
  230. $objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website');
  231. $objPHPExcel->getActiveSheet()->getStyle('E26')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  232. echo date('H:i:s') , " Add a hyperlink to another cell on a different worksheet within the workbook" , EOL;
  233. $objPHPExcel->getActiveSheet()->setCellValue('E27', 'Terms and conditions');
  234. $objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setUrl("sheet://'Terms and conditions'!A1");
  235. $objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setTooltip('Review terms and conditions');
  236. $objPHPExcel->getActiveSheet()->getStyle('E27')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  237. // Add a drawing to the worksheet
  238. echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
  239. $objDrawing = new PHPExcel_Worksheet_Drawing();
  240. $objDrawing->setName('Logo');
  241. $objDrawing->setDescription('Logo');
  242. $objDrawing->setPath('./images/officelogo.jpg');
  243. $objDrawing->setHeight(36);
  244. $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
  245. // Add a drawing to the worksheet
  246. echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
  247. $objDrawing = new PHPExcel_Worksheet_Drawing();
  248. $objDrawing->setName('Paid');
  249. $objDrawing->setDescription('Paid');
  250. $objDrawing->setPath('./images/paid.png');
  251. $objDrawing->setCoordinates('B15');
  252. $objDrawing->setOffsetX(110);
  253. $objDrawing->setRotation(25);
  254. $objDrawing->getShadow()->setVisible(true);
  255. $objDrawing->getShadow()->setDirection(45);
  256. $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
  257. // Add a drawing to the worksheet
  258. echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
  259. $objDrawing = new PHPExcel_Worksheet_Drawing();
  260. $objDrawing->setName('PHPExcel logo');
  261. $objDrawing->setDescription('PHPExcel logo');
  262. $objDrawing->setPath('./images/phpexcel_logo.gif');
  263. $objDrawing->setHeight(36);
  264. $objDrawing->setCoordinates('D24');
  265. $objDrawing->setOffsetX(10);
  266. $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
  267. // Play around with inserting and removing rows and columns
  268. echo date('H:i:s') , " Play around with inserting and removing rows and columns" , EOL;
  269. $objPHPExcel->getActiveSheet()->insertNewRowBefore(6, 10);
  270. $objPHPExcel->getActiveSheet()->removeRow(6, 10);
  271. $objPHPExcel->getActiveSheet()->insertNewColumnBefore('E', 5);
  272. $objPHPExcel->getActiveSheet()->removeColumn('E', 5);
  273. // Set header and footer. When no different headers for odd/even are used, odd header is assumed.
  274. echo date('H:i:s') , " Set header/footer" , EOL;
  275. $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BInvoice&RPrinted on &D');
  276. $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
  277. // Set page orientation and size
  278. echo date('H:i:s') , " Set page orientation and size" , EOL;
  279. $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
  280. $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
  281. // Rename first worksheet
  282. echo date('H:i:s') , " Rename first worksheet" , EOL;
  283. $objPHPExcel->getActiveSheet()->setTitle('Invoice');
  284. // Create a new worksheet, after the default sheet
  285. echo date('H:i:s') , " Create a second Worksheet object" , EOL;
  286. $objPHPExcel->createSheet();
  287. // Llorem ipsum...
  288. $sLloremIpsum = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus eget ante. Sed cursus nunc semper tortor. Aliquam luctus purus non elit. Fusce vel elit commodo sapien dignissim dignissim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Curabitur accumsan magna sed massa. Nullam bibendum quam ac ipsum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin augue. Praesent malesuada justo sed orci. Pellentesque lacus ligula, sodales quis, ultricies a, ultricies vitae, elit. Sed luctus consectetuer dolor. Vivamus vel sem ut nisi sodales accumsan. Nunc et felis. Suspendisse semper viverra odio. Morbi at odio. Integer a orci a purus venenatis molestie. Nam mattis. Praesent rhoncus, nisi vel mattis auctor, neque nisi faucibus sem, non dapibus elit pede ac nisl. Cras turpis.';
  289. // Add some data to the second sheet, resembling some different data types
  290. echo date('H:i:s') , " Add some data" , EOL;
  291. $objPHPExcel->setActiveSheetIndex(1);
  292. $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Terms and conditions');
  293. $objPHPExcel->getActiveSheet()->setCellValue('A3', $sLloremIpsum);
  294. $objPHPExcel->getActiveSheet()->setCellValue('A4', $sLloremIpsum);
  295. $objPHPExcel->getActiveSheet()->setCellValue('A5', $sLloremIpsum);
  296. $objPHPExcel->getActiveSheet()->setCellValue('A6', $sLloremIpsum);
  297. // Set the worksheet tab color
  298. echo date('H:i:s') , " Set the worksheet tab color" , EOL;
  299. $objPHPExcel->getActiveSheet()->getTabColor()->setARGB('FF0094FF');;
  300. // Set alignments
  301. echo date('H:i:s') , " Set alignments" , EOL;
  302. $objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getAlignment()->setWrapText(true);
  303. // Set column widths
  304. echo date('H:i:s') , " Set column widths" , EOL;
  305. $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(80);
  306. // Set fonts
  307. echo date('H:i:s') , " Set fonts" , EOL;
  308. $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setName('Candara');
  309. $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setSize(20);
  310. $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
  311. $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
  312. $objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getFont()->setSize(8);
  313. // Add a drawing to the worksheet
  314. echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
  315. $objDrawing = new PHPExcel_Worksheet_Drawing();
  316. $objDrawing->setName('Terms and conditions');
  317. $objDrawing->setDescription('Terms and conditions');
  318. $objDrawing->setPath('./images/termsconditions.jpg');
  319. $objDrawing->setCoordinates('B14');
  320. $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
  321. // Set page orientation and size
  322. echo date('H:i:s') , " Set page orientation and size" , EOL;
  323. $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
  324. $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
  325. // Rename second worksheet
  326. echo date('H:i:s') , " Rename second worksheet" , EOL;
  327. $objPHPExcel->getActiveSheet()->setTitle('Terms and conditions');
  328. // Set active sheet index to the first sheet, so Excel opens this as the first sheet
  329. $objPHPExcel->setActiveSheetIndex(0);