PHPExcel_Reader_HTML
을 사용하고 있으며 Excel HTML
을 전달하여 Excel 파일을 생성하지만 문제는 'HTML'테이블 에서처럼 셀 색상을 강조 표시하지 않는다는 것입니다 (이미지 불기 참조). 내가 Laravel5PHPExcel_Reader_HTML을 사용하여 Excel 셀을 포맷하는 방법
<?php
$content = $title;
$content .= '<table border="1">';
$content .= '<tr>';
foreach($fields as $f)
{
if($f['download'] =='1') $content .= '<th style="background:#f9f9f9;">'. $f['label'] . '</th>';
}
$content .= '</tr>';
foreach ($rows as $row)
{
$content .= '<tr>';
foreach($fields as $f)
{
if($f['download'] =='1'):
$conn = (isset($f['conn']) ? $f['conn'] : array());
$content .= '<td> '. htmlentities(AjaxHelpers::gridFormater($row->$f['field'],$row,$f['attribute'],$conn)) . '</td>';
endif;
}
$content .= '</tr>';
}
$content .= '</table>';
$path = "../storage/app/".time().".html";
file_put_contents($path, $content);
// Read the contents of the file into PHPExcel Reader class
$reader = new PHPExcel_Reader_HTML;
$content = $reader->load($path);
// Pass to writer and output as needed
$objWriter = PHPExcel_IOFactory::createWriter($content, 'Excel2007');
// Delete temporary file
unlink($path);
// We'll be outputting an excel file
header('Content-type: application/vnd.ms-excel');
// It will be called file.xls
header('Content-disposition: attachment; filename="'.$title.' '.date("d/m/Y").'.xlsx"');
// Write file to the browser
$objWriter->save('php://output');
주를 사용하고 (내 질문에 유래에 요청을받은 질문 후 다른, 내 코딩 시나리오는 모든 다른 ..)
을 강조, 당신은 엑셀에서 CSS, 정말 '다른 다음 질문 stackoverflow'에 요청을받은을 적용 할. – Drone
이미지가'PHPExcel_IOFactory :: createWriter' 객체를 사용하고 있기 때문에 이전에 질문 한 코드를 적용했기 때문에 이미지가 추가되었지만 (내 불운) –
보십시오 : http://stackoverflow.com/questions/36745376/how-to-apply-css-on-html-to-excel-export – Drone