开发者

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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜