Verwendung von 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');
Hinweis:PHPExcel wird jetzt als VERALTET aufgeführt.
Benutzer werden zu PhpSpreadsheet weitergeleitet.
PHPExcel ist veraltet. Sie müssen PhpSpreadsheet verwenden.
Mit PhpSpreadsheet können Sie mit dem folgenden Code csv in xlsx konvertieren:
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Csv');
// If the files uses a delimiter other than a comma (e.g. a tab), then tell the reader
// $reader->setDelimiter("\t");
// If the files uses an encoding other than UTF-8 or ASCII, then tell the reader
// $reader->setInputEncoding('UTF-16LE');
$objPHPExcel = $reader->load('/home/superman/projects/test/csv-app/file.csv');
$objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($objPHPExcel, 'Xlsx');
$objWriter->save('excel_file.xlsx');