How to convert UTF-8 encoded csv to Microsoft Excel xls by PHP?
Is 开发者_StackOverflow社区there an existing PHP module to convert UTF-8 encoded .csv
to an Excel .xls
file? Thanks
Look at using a library such as PHPExcel, which can read spreadsheets in a variety of formats (including CSV) and write to Excel .xls or .xlsx files.
include 'PHPExcel/IOFactory.php';
$inputFileType = 'CSV';
$inputFileName = 'inputFile.csv';
$outputFileType = 'Excel5';
$outputFileName = 'outputFile.xls';
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $outputFileType);
$objWriter->save($outputFileName);
Here is how to do it in PHP http://www.westwideweb.com/wp/2009/01/12/convert-csv-to-xls-excel-in-php/
精彩评论