gpt4 book ai didi

Symfony2 : How do i export the SonataAdminBundle listing data to excel sheet?

转载 作者:行者123 更新时间:2023-12-04 18:22:37 26 4
gpt4 key购买 nike

我需要通过 excel 或 pdf 导出奏鸣曲管理数据。我怎样才能做到这一点?有没有什么包可以帮助我做到这一点?

有任何想法吗!?

谢谢。

最佳答案

您必须覆盖管理员 getExportFields() 方法。

如果实体有一些 (X) 对多或多对 (X) 关系,您必须覆盖所有字段

public function getExportFields()
{
$exportFields = parent::getExportFields(); //It's not working in case of *-to many relation, so remove it, but it's ok for small customisation

$exportFields["Date"] = 'date'; //if your date is an instance of DateTime, you have to format it
$exportFields["User name"] = 'user.name'; // in case of *-to-many relations
$exportFields["Status"] = 'statusAsString'; //for customise format implement getStatusAsString() in you entity
return $exportFields;
}

要自定义要下载的报告类型,您必须覆盖,删除默认的:
public function getExportFormats()
{
return array(
'json', 'xml', 'csv', 'xls'
);
}

关于Symfony2 : How do i export the SonataAdminBundle listing data to excel sheet?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10346806/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com