我正在尝试将自定义css样式应用于导出的文件,例如pdf。
例如,如何在pdf导出中应用自定义CSS样式?
我在styleOptions
中更改了一些字体样式,但没有任何结果。
<?= ExportMenu::widget([
'target' => ExportMenu::TARGET_SELF,
'dataProvider' => $dataProvider,
'columns' => $report_columns,
'fontAwesome' => true,
'dropdownOptions' => [
'label' => Yii::t('app','Export All'),
'class' => 'btn btn-default'
],
'styleOptions' => [
'font' => [
'size' => '24px',
'bold' => true,
'color' => [
'argb' => 'FFFFFFFF',
],
],
'fill' => [
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => [
'argb' => '00000000',
],
],
],
'exportConfig' => [
ExportMenu::FORMAT_CSV => false,
ExportMenu::FORMAT_EXCEL => false,
ExportMenu::FORMAT_EXCEL_X => false,
ExportMenu::FORMAT_TEXT => false,
//ExportMenu::FORMAT_PDF => false,
//ExportMenu::FORMAT_HTML => false
]
]) . "<hr>\n".
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => $columns,
'pjax' => true,
'summary' => '',
'options' => ['class' => 'xxx', 'style'=>'padding-right:10px']
]);
?>
答案 0 :(得分:0)
必须将styleOptions设置为关联数组,因为它在导出菜单中的styleOptions设置文档中进行了更新: http://demos.krajee.com/export#option-styleOptions
'styleOptions' => [
ExportMenu::FORMAT_EXCEL_X => [
'font' => [
'size' => '24px',
'bold' => true,
'color' => [
'argb' => 'FFFFFFFF',
],
],
'fill' => [
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => [
'argb' => '00000000',
],
],
],
],
并确保您正确导入PHPExcel_Style_Fill。