XLSProjectList_my.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <?
  2. header("Expires: 0");
  3. session_start();
  4. require_once 'PHPExcel-1.8.2/Classes/PHPExcel.php';
  5. include 'auth.php';
  6. include 'functions.php';
  7. require_once "doctrine/bootstrap.php";
  8. include 'CheckPoint.php';
  9. include 'CheckPointType.php';
  10. use CheckPoints\CheckPoint;
  11. use CheckPointTypes\CheckPointType;
  12. global $companyID;
  13. //global $link;
  14. $companyID = $_SESSION['company'];
  15. $sort = $_SESSION['proj_sort'];
  16. $activeid = (int)$_GET['activeid'];
  17. $parents = $entityManager->getRepository('Task')->findBy(array('input_id' => $activeid , 'parent_id' => 0), array('id' => 'DESC'));
  18. $tasktypes = GrabTasktypes();
  19. $tasktypesIds = GrabTasktypesIDs();
  20. //var_dump($_SESSION['array_tasksid']);
  21. //exit;
  22. $arrayMain = [];
  23. $query = mysqli_query($link, "SELECT write_to_twx,name FROM checkpoint_types");
  24. $arrayTwx = [];
  25. while ($checkpoint_arr = mysqli_fetch_array($query))
  26. {
  27. $arrayTwx[$checkpoint_arr['name']] = $checkpoint_arr['write_to_twx'];
  28. }
  29. foreach($_SESSION['array_tasksid'] as $activeid) {
  30. foreach ($parents as $parent) {
  31. if (!in_array(intval($parent->type), $tasktypesIds))
  32. continue;
  33. $status = GetTaskStatus($parent->id);
  34. if ($status == intval($sort)) {
  35. $array_parent[$parent->id] = $parent;
  36. $children = $entityManager->getRepository('Task')->findBy(array('parent_id' => $parent->id));
  37. $array_children[$parent->id] = $children;
  38. }
  39. }
  40. $array_type = [];
  41. $array_id = [];
  42. foreach ($array_children as $parent_id => $children) {
  43. if ($activeid == $parent_id) {
  44. foreach ($children as $res1) {
  45. //EchoTask2($res1, $activeid, false);
  46. $array_type[] = $res1->type;
  47. $array_id[] = $res1->id;
  48. }
  49. }
  50. }
  51. $arResult = [];
  52. //$res = explode(',',$array_type);
  53. //$ids = explode(',',$array_id);
  54. $res = $array_type;
  55. $ids = $array_id;
  56. $arrIds = [];
  57. foreach($res as $key => $r){
  58. $arrIds[$ids[$key]] = $r;
  59. }
  60. foreach($arrIds as $key => $r){
  61. $tenpArray = [];
  62. $type = Tasktype::Find($r);
  63. $tenpArray['name'] = $type->name;
  64. $arResult[$key] = $tenpArray;
  65. }
  66. //echo '<pre><h3>Шаг 1.</h3><br/>'; var_dump($arResult); echo '<pre>'; die();
  67. foreach($arResult as $key => $id){
  68. $notes = FindTaskNotes($key);
  69. $tenpArray = [];
  70. foreach ($notes as $note) {
  71. $tenpArray[] = explode(', TWX',$note['text'])[0];
  72. }
  73. $arResult[$key]['notes'] = $tenpArray;
  74. }
  75. //echo '<pre><h3>Шаг 2.</h3><br/>'; var_dump($arResult); echo '<pre>'; die();
  76. foreach($arResult as $key => $id){
  77. $cps = CheckPoint::FindAllByTask($key);
  78. $tenpArray = [];
  79. foreach ($cps as $cp) {
  80. // var_dump($cp->name);echo "<br>";
  81. $textnotes = $entityManager->getRepository('Tasknote')->findBy(array('checkpoint_id' => $cp->id));
  82. /*foreach($cp as $key => $tt) {
  83. var_dump($key ."=>".$tt );
  84. }
  85. echo "<br>";*/
  86. $noteType = '';
  87. if ( 0 != count($textnotes)) {
  88. $noteType = 'Замечание: ';
  89. }
  90. foreach ($textnotes as $tn)
  91. {
  92. $noteType .= $tn->text.', ';
  93. }
  94. $noteType = substr_replace($noteType, ' ', -2);
  95. $temArray = [];
  96. $tenpArray['name'] = $cp->name;
  97. $tenpArray['notesType'] = $noteType;
  98. if ($cp->value != null){
  99. //echo $cp->value;
  100. $temArray[] = $cp->value;
  101. } else {
  102. $children = $cp->childrenCheckpoints;
  103. foreach ($children as $child) {
  104. if ( 1 == $child->state) {
  105. $temArray[]= $child->name;
  106. //var_dump($arrayTwx[$child->name]);
  107. }
  108. //$temArray[] = $child->name;
  109. //echo "$child->name: $child->value $child->state<br>";
  110. }
  111. }
  112. $tenpArray['value'] = implode(',',$temArray);
  113. if ( 1 != $arrayTwx[$tenpArray['value']] ) {
  114. $tenpArray['grey'] = 1;
  115. } else {
  116. $tenpArray['grey'] = 0;
  117. }
  118. if (!empty($tenpArray['value']) && '' != $tenpArray['value']){
  119. $arResult[$key]['maps'][] = $tenpArray;
  120. }
  121. }
  122. }
  123. //echo '<pre><h3>Шаг 3.</h3><br/>'; var_dump($arResult); echo '<pre>'; die();
  124. $rrr = [];
  125. foreach($arResult as $res){
  126. $temp = [];
  127. foreach($res['notes'] as $r){
  128. $temp['name'] = $res['name'];
  129. $temp['desc'] = $r;
  130. $rrr[] = $temp;
  131. }
  132. $temp = [];
  133. foreach($res['maps'] as $b){
  134. /*$temp['name'] = $b['name'];
  135. $temp['desc'] = $b['value'];/**/
  136. $temp['color'] = $b['grey'];
  137. $temp['name'] = $res['name'];
  138. $temp['desc'] = $b['name'].': '.$b['value'].'. '. $b['notesType'];
  139. $rrr[] = $temp;
  140. }
  141. }
  142. $arResult = $rrr;
  143. $arResult['namedesc'] = GetTaskNameAndDesc($array_parent[$activeid]->type)[0];
  144. $finished = [];
  145. foreach ($array_children as $parent_id => $children) {
  146. if ($activeid != $parent_id)
  147. {
  148. continue;
  149. }
  150. foreach ($children as $res1) {
  151. foreach ($res1 as $key => $res) {
  152. switch ($key) {
  153. case 'accepted_time':
  154. $finished[] = $res;
  155. break;
  156. case 'account':
  157. foreach ($res as $acckey => $accval) {
  158. if ($acckey == 'name') {
  159. $assignee_names[] = $accval;
  160. break;
  161. }
  162. }
  163. break;
  164. }
  165. }
  166. }
  167. }
  168. rsort($finished);
  169. $finished_datetime = $finished[0];
  170. foreach($finished_datetime as $key => $res){
  171. if ( 'date' == $key ) {
  172. $finished_datetime = $res;
  173. }
  174. }
  175. $arResult['finished'] = date('Y-m-d H:i:s', strtotime($finished_datetime));
  176. $arrayMain[] = $arResult;
  177. // break;
  178. }
  179. //exit;
  180. //exit;
  181. //echo "<pre>";
  182. //var_dump($arrayMain);
  183. //echo "</pre>";
  184. //var_dump($_SESSION['array_tasksid']);
  185. //exit;
  186. //echo '<pre><h3>Шаг 4.</h3><br/>'; var_dump($arResult); echo '<pre>'; die();
  187. /*
  188. var_dump($rrr);
  189. exit;
  190. */
  191. function cellColor($cells,$color){
  192. global $objPHPExcel;
  193. $objPHPExcel->getActiveSheet()->getStyle($cells)->getFill()->applyFromArray(array(
  194. 'type' => PHPExcel_Style_Fill::FILL_SOLID,
  195. 'startcolor' => array(
  196. 'rgb' => $color
  197. )
  198. ));
  199. }
  200. $styleBorder = array(
  201. 'borders' => array(
  202. 'allborders' => array(
  203. 'style' => PHPExcel_Style_Border::BORDER_THIN
  204. )
  205. )
  206. );
  207. foreach (array_keys($_REQUEST) as $var)
  208. {
  209. ${$var}=$_REQUEST[$var];
  210. //echo "<b>$var:</b> ${$var} <br>";
  211. }
  212. $array_children = $_SESSION['array_children'];
  213. $array_parent = $_SESSION['array_parent'];
  214. $activeid = $_SESSION['actid'];
  215. $lastActiveId = array_pop($_SESSION['array_tasksid']);
  216. //$res_parent = $array_parent[$activeid];
  217. $res_parent = $array_parent[$lastActiveId];
  218. foreach($res_parent as $key => $r) {
  219. if ('type' == $key){
  220. $res_parent_type = $r;
  221. }
  222. if ('input_id' == $key){
  223. $res_parent_input_id = $r;
  224. }
  225. if ( 'created' == $key) {
  226. $res_parent_created = $r;
  227. }
  228. }
  229. //echo "<pre>";
  230. //var_dump($activeid);echo "<br>";
  231. //var_dump($array_children);echo "<br>";
  232. //echo "</pre>";
  233. //exit;
  234. $namedesc = GetTaskNameAndDesc($res_parent_type);
  235. //$namedesc = GetTaskNameAndDesc($res_parent['type']);
  236. $proj = GetProject($res_parent_input_id);
  237. //$proj = GetProject($res_parent['input_id']);
  238. $depo = $proj['depo'];
  239. $depo_service = $proj['depo_service'];
  240. $project_finished = $res_parent_created;
  241. //echo '<pre><h3>Шаг 1.</h3><br/>'; var_dump($finished); echo '<pre>'; die();
  242. //$finished = $res_parent['created'];
  243. // Create new PHPExcel object
  244. $objPHPExcel = new PHPExcel();
  245. // Set document properties
  246. $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
  247. ->setLastModifiedBy("Maarten Balliauw")
  248. ->setTitle("Office 2007 XLSX Report Document")
  249. ->setSubject("Office 2007 XLSX Report Document")
  250. ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
  251. ->setKeywords("office 2007 openxml php")
  252. ->setCategory("Report result file");
  253. $style = array(
  254. 'alignment' => array(
  255. 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
  256. )
  257. );
  258. $style1 = array(
  259. 'alignment' => array(
  260. 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_RIGHT,
  261. )
  262. );
  263. $style2 = array(
  264. 'alignment' => array(
  265. 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
  266. )
  267. );
  268. $sheet = $objPHPExcel->getActiveSheet();
  269. $sheet->getDefaultStyle()->getFont()->setName('Times New Roman')->setSize(11);
  270. $sheet->getStyle("C3")->applyFromArray($style);
  271. $objPHPExcel->getActiveSheet()->getStyle('B11:E11')->applyFromArray($styleBorder);
  272. cellColor('B11:E11', 'f2f2f2');
  273. $sheet->getRowDimension('1')->setRowHeight(31.5);
  274. $sheet->getRowDimension('2')->setRowHeight(31.5);
  275. $sheet->getRowDimension('3')->setRowHeight(31.5);
  276. $sheet->getRowDimension('4')->setRowHeight(31.5);
  277. $sheet->getRowDimension('5')->setRowHeight(16.5);
  278. $sheet->getRowDimension('6')->setRowHeight(1);
  279. $sheet->getRowDimension('7')->setRowHeight(1);
  280. $sheet->getRowDimension('8')->setRowHeight(1);
  281. $sheet->getRowDimension('9')->setRowHeight(1);
  282. $sheet->getRowDimension('10')->setRowHeight(1);
  283. $sheet->getRowDimension('11')->setRowHeight(40);
  284. //$sheet->getRowDimension('1')->setRowHeight(31.5);
  285. $sheet->getStyle('C2')->getFont()->setBold(TRUE);
  286. $objPHPExcel->setActiveSheetIndex(0)->setCellValue('C2', "АКТ ПРИЕМКИ НА ПЛАНОВЫЙ РЕМОНТ.");
  287. $objPHPExcel->setActiveSheetIndex(0)->setCellValue('C3', "Локомотив серия ".$proj['loco_type']." номер ".$proj['loco_number']);
  288. $sheet->mergeCells('A1:B1');
  289. $sheet->mergeCells('B11:C11');
  290. //$objPHPExcel->setActiveSheetIndex(0)->setCellValue('D2', 'Проект №'.$proj['id']);
  291. //cellColor('A1:J1', '8DB4E2');
  292. $sheet->getStyle('C3')->getFont()->setBold(TRUE);
  293. $sheet->getStyle('B11:D11')->getFont()->setBold(TRUE);
  294. //$sheet->getStyle('B3:B6')->getFont()->setBold(TRUE);
  295. //$sheet->setCellValue('B11', '№ п/п');
  296. $i=13;
  297. $k=1;
  298. foreach( $arrayMain as $mainItem) {
  299. $sub = $i-1;
  300. $sheet->setCellValue('C'.$sub, $mainItem['namedesc']);
  301. $sheet->getStyle('C'.$sub)->getFont()->setBold(TRUE);
  302. //echo $mainItem['namedesc']; echo "<br>";
  303. //echo $mainItem['namedesc'] . '<br>';
  304. //echo "<pre>";
  305. //var_dump($mainItem);
  306. //echo "</pre>";
  307. foreach($mainItem as $key => $item){
  308. if(strlen($item['desc']) <= 100){
  309. $heigt = 15;
  310. }elseif(strlen($item['desc']) <= 200){
  311. $heigt = 35;
  312. }elseif(strlen($item['desc']) <= 300){
  313. $heigt = 55;
  314. }
  315. $sheet->getRowDimension($i)->setRowHeight($heigt);
  316. $sheet->getStyle("C".$i)->getAlignment()->setWrapText(true);
  317. $sheet->getStyle('B'.$i)->getFont()->setBold(TRUE);
  318. /*echo $item['name'];
  319. //var_dump(( null == $item['name']));
  320. //var_dump((in_array($key,['namedesc','finished'])));
  321. echo $item['desc'];*/
  322. //var_dump($item);
  323. //echo "<br>";
  324. //var_dump("KEY => " .$key . " in_array = ". ( in_array($key,['namedesc','finished'])));echo "<br>";
  325. if ( $key !== 0 ){
  326. if( $key and in_array($key,['namedesc','finished'])) { continue;}
  327. }
  328. //var_dump($item['name'].'!'); echo "<br>";
  329. $descExplode = explode('__',$item['desc']);
  330. if( 1 == $item['color'] ) {
  331. cellColor('C'.$i, 'f2f2f2');
  332. //$item['desc'] = substr($item['desc'],3);
  333. }
  334. $sheet->setCellValue('B'.$i, $k); //echo $k;
  335. // $sheet->setCellValue('C'.$i, $item['name']); //echo $item['name'];
  336. $sheet->setCellValue('C'.$i, $item['desc']);
  337. //$sheet->setCellValue('D'.$i, $key .'->'.in_array($key,['namedesc','finished']));
  338. $i++;
  339. $k++;
  340. }
  341. //$sud2 = $i + 1;
  342. //if (empty($finished_datetime))
  343. // $sheet->setCellValue('B'.$sud2, "Дата окончания осмотра: не завершена");
  344. //else
  345. //$sheet->setCellValue('B'.$sud2, "Дата окончания: " . $mainItem['finished']);
  346. $i += 2;
  347. //$k=1;
  348. }
  349. $i -= 2;
  350. for($m=$k;$m<$k+10;$m++){
  351. $sheet->getStyle('B'.$i)->getFont()->setBold(TRUE);
  352. $sheet->setCellValue('B'.$i, $m);
  353. //$sheet->setCellValue('B'.$i, ' ');
  354. $i++;
  355. }
  356. $i2 = $i + 2;
  357. $sheet->setCellValue('C'.$i2, '____________________________­­­­______________________');
  358. $i2 += 1;
  359. $sheet->setCellValue('C'.$i2,'____________________________­­­­______________________');
  360. //exit;
  361. $sheet->setCellValue('B11', 'Замечание бригадира приемки по работе электровоза');
  362. $sheet->setCellValue('D11', 'Ф.И.О., роспись исполнителя');
  363. $sheet->getStyle("D11")->getAlignment()->setWrapText(true);
  364. $sheet->setCellValue('E11', 'Роспись мастера (бригадира)');
  365. $sheet->getStyle('A10:L11')->getFont()->setBold(TRUE);
  366. $objPHPExcel->getActiveSheet()->getStyle("C3")->getFont()->setSize(18);
  367. $objPHPExcel->getActiveSheet()->getStyle("C2")->getFont()->setSize(18);
  368. //$objPHPExcel->getActiveSheet()->getStyle("C3:C4")->getFont()->setSize(18);
  369. //$sheet->setCellValue('C3', 'Акт №');
  370. //$sheet->setCellValue('C4', $namedesc[0]);
  371. $sheet->setCellValue('C4', 'Дата приемки­­­­__________');
  372. $sheet->setCellValue('C5', "Электровоз серия________№__________ ");
  373. $sheet->setCellValue('D5', " Вид ремонта___________");
  374. //$sheet->setCellValue('C6', 'Настоящий акт подверждает, что '.$project_finished->date);
  375. //$sheet->setCellValue('C7', "На локомотиве серии ".$proj['loco_type']." номер ".$proj['loco_number']);
  376. //$sheet->setCellValue('C8', "Приписки локомотивного депо: $depo");
  377. //$sheet->setCellValue('C9', 'В ходе приемки, испытания, осмотра и ремонта Локомотива необходимо проведение следующих работ:');
  378. //$sheet->getStyle('C9')->getFont()->setBold(TRUE);
  379. //$sheet->setCellValue('C2', 'Значение');
  380. //cellColor('A10:L10', '8DB4E2');
  381. $sheet->getStyle('B11')->getFont()->setBold(TRUE);
  382. $sheet->getStyle('B10')->getFont()->getColor()->setRGB('FFFFFF');
  383. //$i=12;
  384. $finished = [];
  385. $assignee_names = [];
  386. //echo '<pre><h3>Шаг 2.</h3><br/>'; var_dump($array_children); echo '<pre>'; die();
  387. foreach ($array_children as $parent_id => $children)
  388. {
  389. //echo '<pre><h3>Шаг 2.</h3><br/>'; var_dump($children); echo '<pre>'; die();
  390. if ($activeid != $parent_id)
  391. {
  392. continue;
  393. }
  394. foreach ($children as $res1) {
  395. foreach ($res1 as $key => $res)
  396. {
  397. switch ($key)
  398. {
  399. case 'accepted_time':
  400. $finished[] = $res;
  401. break;
  402. case 'account':
  403. foreach ($res as $acckey => $accval)
  404. {
  405. if ($acckey == 'name')
  406. {
  407. $assignee_names[] = $accval;
  408. break;
  409. }
  410. }
  411. break;
  412. }
  413. }
  414. $taskid = $res1->id;
  415. $type = $res1->type;
  416. $created = $res1->created;
  417. //$accepted = $res1->accepted_time;
  418. //$finished[] = $res1->finished_time;
  419. //$finished[] = $res1->accepted_time->date;
  420. //$assignee = $res1->assignees_arr;
  421. //$assignee_names[] = $res1->name;//GetAccount($assignee)['name'];
  422. //if ($finished == '')
  423. // $finished = 'не завершена';
  424. //if ($accepted == '')
  425. // $accepted = 'не принята';
  426. $namedesc = GetTaskNameAndDesc($type);
  427. // $sheet->setCellValueByColumnAndRow(0, $i, $taskid);
  428. // $sheet->setCellValueByColumnAndRow(1, $i, $namedesc[0]);
  429. // $sheet->setCellValueByColumnAndRow(2, $i, $namedesc[1]);
  430. // $sheet->setCellValueByColumnAndRow(3, $i, $finished);
  431. // $sheet->setCellValueByColumnAndRow(4, $i, $assignee_names);
  432. // $sheet->setCellValueByColumnAndRow(5, $i, $namedesc[1]);
  433. // $sheet->setCellValueByColumnAndRow(6, $i, $assignee_names);
  434. $notes = FindTaskNotes($taskid);
  435. if (sizeof($notes) > 0) {
  436. $nn = 2;
  437. $num = 0;
  438. $notestext = "$taskid. \n";
  439. foreach ($notes as $note) {
  440. $num++;
  441. // if ($num == 3)
  442. // break;
  443. $notedate = $note['date'];
  444. $noteid = $note['id'];
  445. $notetext = $note['text'];
  446. //$sheet->setCellValueByColumnAndRow($nn, $i, $noteid." [".$notedate."] ".$notetext);
  447. $sheet->getStyle('C'.$i)->getAlignment()->setWrapText(true);
  448. $sheet->getStyle('D'.$i)->getAlignment()->setWrapText(true);
  449. $sheet->getStyle('E'.$i)->getAlignment()->setWrapText(true);
  450. $sheet->getStyle('F'.$i)->getAlignment()->setWrapText(true);
  451. $sheet->getStyle('G'.$i)->getAlignment()->setWrapText(true);
  452. $notestext .= $num.". ".$notetext."\n";
  453. //$nn++;
  454. }
  455. $sheet->setCellValueByColumnAndRow($nn, $i, $notestext);
  456. $i++;
  457. }
  458. }
  459. }
  460. $i--;
  461. $sheet->getStyle("B12:E".$i)->applyFromArray($styleBorder);
  462. $i+=2;
  463. $sheet->getRowDimension($i)->setRowHeight(25);
  464. rsort($finished);
  465. $finished_datetime = $finished[0];
  466. //echo '<pre><h3>Шаг 2.</h3><br/>'; var_dump($finished_datetime); echo '<pre>'; die();
  467. //if (empty($finished_datetime))
  468. // $sheet->setCellValueByColumnAndRow(2, $i, 'Дата окончания осмотра: не завершена');
  469. //else
  470. // $sheet->setCellValueByColumnAndRow(2, $i, 'Дата окончания осмотра: '.date('Y-m-d H:i:s', strtotime($finished_datetime->date)));
  471. $i+=2;
  472. $sheet->getRowDimension($i)->setRowHeight(30);
  473. $assignee_names = array_unique($assignee_names);
  474. //echo '<pre><h3>Шаг 2.</h3><br/>'; var_dump($assignee_names); echo '<pre>'; die();
  475. //$sheet->setCellValueByColumnAndRow(2, $i, 'Исполнитель: '.implode(',', $assignee_names));
  476. // Rename worksheet
  477. $sheet->setTitle('Report');
  478. // Set active sheet index to the first sheet, so Excel opens this as the first sheet
  479. $objPHPExcel->setActiveSheetIndex(0);
  480. $sheet->getColumnDimension('A')->setWidth(1);
  481. $sheet->getColumnDimension('B')->setWidth(4.14);
  482. $sheet->getColumnDimension('C')->setWidth(51.29);
  483. $sheet->getColumnDimension('D')->setWidth(15.29);
  484. $sheet->getColumnDimension('E')->setWidth(15.29);
  485. $sheet->getColumnDimension('F')->setWidth(51.29);
  486. $sheet->getColumnDimension('G')->setWidth(51.29);
  487. $sheet->getColumnDimension('H')->setAutoSize(true);
  488. $sheet->getColumnDimension('I')->setAutoSize(true);
  489. $sheet->getColumnDimension('J')->setAutoSize(true);
  490. $sheet->getColumnDimension('K')->setAutoSize(true);
  491. $sheet->getColumnDimension('L')->setAutoSize(true);
  492. $sheet->getColumnDimension('M')->setAutoSize(true);
  493. //foreach($sheet->getRowDimensions() as $rd) {
  494. //$rd->setRowHeight(-1);
  495. //}
  496. $objPHPExcel->getActiveSheet()->getStyle('E11')->getAlignment()->setWrapText(true);
  497. $sheet->getStyle("A10:M10")->applyFromArray($style2);
  498. $styleBorder = array('font' => array('bold' => true));
  499. $sheet->getStyle('B1:F1')->applyFromArray($styleBorder);
  500. $sheet->getStyle('A1')->getFont()->setBold(TRUE);
  501. // Redirect output to a client’s web browser (Excel5)
  502. header('Content-Type: application/vnd.ms-excel');
  503. $date1 = date('Y.m.d-H.i', strtotime($project_finished->date));
  504. header('Content-Disposition: attachment;filename="'.$date1.'-'.$proj['loco_type'].'-'.$proj['loco_number'].'.xls"');
  505. header('Cache-Control: max-age=0');
  506. // If you're serving to IE 9, then the following may be needed
  507. header('Cache-Control: max-age=1');
  508. // If you're serving to IE over SSL, then the following may be needed
  509. header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  510. header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
  511. header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  512. header ('Pragma: public'); // HTTP/1.0
  513. $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
  514. //$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  515. $objWriter->save('php://output');
  516. ?>