XLSProjectList.php 22 KB

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