Php 如何将HTML上的CSS应用于Excel导出
我试图使用php标题将HTML导出为Excel格式,但CSS样式并没有应用于元素(在导出为Excel文件时),我也尝试实现引导类,但没有成功 注意:在应用引导类时,我在html中包含bootstrap.css 有什么方法可以应用CSS吗 使用Php 如何将HTML上的CSS应用于Excel导出,php,html,excel,laravel-5.1,Php,Html,Excel,Laravel 5.1,我试图使用php标题将HTML导出为Excel格式,但CSS样式并没有应用于元素(在导出为Excel文件时),我也尝试实现引导类,但没有成功 注意:在应用引导类时,我在html中包含bootstrap.css 有什么方法可以应用CSS吗 使用 header('Content-type: application/excel'); header("Content-Disposition: attachment; filename=\"$filename\""); 示
header('Content-type: application/excel');
header("Content-Disposition: attachment; filename=\"$filename\"");
示例HTML元素
<table width="100%" border="1" class="table table-striped table-bordered">
<thead>
<tr>
<td colspan="9" style="font-weight: bold; font-size: 16px; text-align: center;"><h2>Push Notification </h2></td>
</tr>
<tr><td colspan="9"></td></tr>
</thead>
<tbody>
<tr class="heading">
<th colspan="2" ></th>
<th style="width:2% !important">S.no</th>
<th style="width:10% !important">Date</th>
<th style="width:10% !important">App</th>
<th style="width:20%">Category</th>
<th colspan="2" style="width:50%">Message</th>
</tr>
@if($push_notifications->count() > 0)
<?php $counter = 1; ?>
@foreach($push_notifications as $notification)
<tr @if(($counter %2) ==1) bcolor="#c9c9c9" @endif>
<td colspan="2"></td>
<td style="width:2% !important">{!!$counter!!}</td>
<td style="width:10% !important">{!!$notification->date!!}</td>
<td style="width:10% !important">{!!$notification->notificationAppType->name!!}</td>
<td style="width:20%">{!!$notification->notificationCategory->name!!}</td>
<td colspan="2" style="width:50%">{!!htmlentities($notification->message, ENT_QUOTES)!!}</td>
</tr>
<?php $counter++; ?>
@endforeach
@else
<tr>
<td colspan="9">No record available</td>
</tr>
@endif
</tbody>
</table>
推送通知
序号
日期
应用程序
类别
消息
@如果($push_notifications->count()>0)
@foreach($push_通知作为$notification)
{!!$counter!!}
{!!$notification->date!!}
{!!$notification->notificationAppType->name!!}
{!!$notification->notificationCategory->name!!}
{!!htmlentities($notification->message,ENT_QUOTES)!!}
@endforeach
@否则
没有可用的记录
@恩迪夫
简短的回答是不,您不能将css应用于excel
但是,您可以对excel文件的文本应用某些格式,但格式的数量受生成excel文件所用的库以及excel本身允许的格式限制。试试PHPExcel:您能提供适用于excel的样式格式列表吗?这是一个完全不同的问题。请创建另一个(当然,在对库中的文档进行搜索后,您将使用这些文档生成它)