0

代码

我的奏鸣曲管理类代码:

class UsersAdmin extends AbstractAdmin
{
.....
    protected function configureListFields(ListMapper $listMapper)
    {

        $listMapper
            ->add('getSummaryTimeInGame','string',[
                'label'    => 'Summary time in game',
                'template' =>'AdminBundle::get_summary_time_in_game.html.twig'
            ])
            ->add('getPercentTasksDone', 'string', [
                'label'    => 'Percents tasks done',
                'template' => 'AdminBundle::get_percent_tasks_done.html.twig'
            ])
    }

   public function getExportFields()
   {
       return [
            'Name'     => 'name',
            'Surname'  => 'surname',
            'Summary time in game' => 'getSummaryTimeInGame',
            'Percents tasks done'  => 'getPercentTasksDone',
       ];
   }

.....
}

问题

字段 'getSummaryTimeInGame' 和 'getPercentTasksDone' 在数据网格列表视图中可见,但在导出到 XLS 时,它们是空白的

如何在 XLS 导出中正确列出这些字段?

4

1 回答 1

0

在您的用户实体(链接到此管理类的实体)中创建这两个函数。

public function getSummaryTimeInGame{
    // return the desired calculated value.
}

public function getPercentTasksDone(){
    // return the desired calculated value.
}

在此之后导出您的工作表并将在您的文件中获取这些值。

于 2019-05-06T18:10:15.333 回答