CSV转换为Excel

有没有一种方法可以通过apache / .htaccess将CSV文件转换为Excel文件

回答:

使用PHPExcel

include 'PHPExcel/IOFactory.php';

$objReader = PHPExcel_IOFactory::createReader('CSV');

// If the files uses a delimiter other than a comma (e.g. a tab), then tell the reader

$objReader->setDelimiter("\t");

// If the files uses an encoding other than UTF-8 or ASCII, then tell the reader

$objReader->setInputEncoding('UTF-16LE');

$objPHPExcel = $objReader->load('MyCSVFile.csv');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

$objWriter->save('MyExcelFile.xls');

以上是 CSV转换为Excel 的全部内容, 来源链接: utcz.com/qa/432735.html

回到顶部