我使用kartik导出小部件(ExportMenu),并且想要更改Excel工作表中的样式。我想要一张没有边框的桌子。我已经尝试过了:
$style = [
'borders' => [
'outline' => [
'borderStyle' => Border::BORDER_NONE,
],
'inside' => [
'borderStyle' => Border::BORDER_NONE,
]
],
];
$exportMenu = ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'exportConfig' => [
ExportMenu::FORMAT_TEXT => false,
ExportMenu::FORMAT_HTML => false,
ExportMenu::FORMAT_PDF => false,
ExportMenu::FORMAT_CSV => false,
ExportMenu::FORMAT_EXCEL => false,
ExportMenu::FORMAT_EXCEL_X => $style,
],
]);
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'panel' => [
'type' => GridView::TYPE_PRIMARY,
'heading' => '',
],
'exportContainer' => [
'class' => 'btn-group mr-2'
],
'toolbar' => [
$exportMenu,
'options' => ['class' => 'btn-group']
],
]);
我已经阅读了文档(http://demos.krajee.com/export),实际上它应该以这种方式工作。但是什么都没有改变。请帮忙!
答案 0 :(得分:0)
我已经解决了以下问题:
$exportMenu = ExportMenu::widget([
'dataProvider' => $dataProvider],
'autoXlFormat'=> false,
'columns' => $gridColumns,
'exportConfig' => [
ExportMenu::FORMAT_TEXT => false,
ExportMenu::FORMAT_HTML => false,
ExportMenu::FORMAT_PDF => false,
ExportMenu::FORMAT_CSV => false,
ExportMenu::FORMAT_EXCEL => false,
],
'boxStyleOptions' => [
ExportMenu::FORMAT_EXCEL_X => [
'borders' => [
'outline' => [
'borderStyle' => Border::BORDER_NONE,
],
'inside' => [
'borderStyle' => Border::BORDER_NONE,
],
],
],
],
'exportContainer' => [
'class' => 'btn-group mr-2'
],
'dropdownOptions' => [
'label' => Yii::t('app/importExport', 'Export'),
'class' => 'btn btn-secondary',
],
'filename' => $dataProviderExport["fileName"],
]);