public function export($tpl, $filename, $header, $columnWidth)
{$data = [];
$headerFields = array_keys($header);
$headerTitles = array_values($header);
$templateDataItem = $this->getDataItemByTpl($tpl);
$result = TemplateCatService::S()->getTemplateCatKVByTpl($tpl);
foreach ($templateDataItem as $key => &$dataItem) {$dataItem->unpack();
$dataItem->catName = $result[$dataItem->catId];
$dataItem->bCatName = $result[$dataItem->bCatId];
$dataItem->labels = implode(",", $dataItem->labels);
// 上面的代码是我之前没有想到的
foreach ($headerFields as $field) {$data[$key][$field] = $dataItem->$field;
}
}
return \Util::export($headerTitles, $data, $filename, $columnWidth);
}