我有一个使用 PHPExcel 生成 Excel 工作表的简单代码。在代码中,我试图计算列宽,但它给出的列宽为 -1。我做错了什么?
<?php
require '../PHPExcel_1.7.8-with_documentation-msoffice_format/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->getActiveSheet()->setCellValue('A1','Test Column Width');
$calculatedWidth = $objPHPExcel->getActiveSheet()->getColumnDimension('A')->getWidth();
$objPHPExcel->getActiveSheet()->setCellValue('B1',$calculatedWidth);
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename="Technical.xlsx"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
?>