我正在从 Magento 进行 excel 导出。我希望自动调整列的大小。这是我尝试过的代码,
public function exportOrders($orders)
{
$fileName = 'order_export_'.date("Ymd_His").'.csv';
$fp = fopen(Mage::getBaseDir('export').'/'.$fileName, 'w');
$this->writeHeadRow($fp);
foreach ($orders as $order) {
$order = Mage::getModel('sales/order')->load($order);
$this->writeOrder($order, $fp);
}
for($i = $fromCol; $i !== $toCol; $i++) {
$calculatedWidth = $sheet->getColumnDimension($i)->getWidth();
$sheet->getColumnDimension($i)->setWidth((int) $calculatedWidth * 2);
}
fclose($fp);
return $fileName;
}
它似乎不起作用。