gpt4 book ai didi

php - magento 中的 getcsv() 和 getcsvfile() 方法有什么区别?

转载 作者:可可西里 更新时间:2023-10-31 23:40:43 25 4
gpt4 key购买 nike

我正在尝试将 AdminHtml 网格导出到 CSV。我找到了两种方法 getCsv() 和 getCsvFile() 用于将结果网格导出到 CSV 文件中。谁能告诉我这两个函数有什么区别?

方法-1

$fileName = "filename.csv";
$content = $this->getLayout()->createBlock('custom_modelue/adminhtml_report_grid')
->getCsv();
$this->_prepareDownloadResponse($fileName, $content);

方法-2

$fileName = "filename.csv";
$content = $this->getLayout()->createBlock('custom_modelue/adminhtml_report_grid')
->getCsvFile();
$this->_prepareDownloadResponse($fileName, $content);

当我使用方法 -1 时,过滤器不会应用于导出 CSV 结果。但在方法-2 中,过滤器应用于结果集。

最佳答案

getCsv() 和 getCsvFile() 的区别如下

get CsvFile() is 

Retrieve a file container array by grid data as CSV

Return array with keys type and value

return array

在大多数情况下,getcsvFile 用于将网格包含导出到 magen 中的 csv 到系统

  and getCsv() is 
Retrieve Grid data as CSV
and return string

关于php - magento 中的 getcsv() 和 getcsvfile() 方法有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22452486/

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