将文件从XLS转换为CSV

时间:2015-08-18 10:51:15

标签: php sql-server-2008 batch-processing

我正在尝试编写一个脚本,将所有文件xls转换为csv,但是当我尝试运行它时,我会出现此错误

  

致命错误:未捕获的异常' PHPExcel_Reader_Exception'有消息'无法打开../public/mad/export_tarifs.xls进行阅读!文件不存在。'在第443行的C:\ wamp \ www \ chaima \ speed-wear.net \ web \ batchs \ Classes \ PHPExcel \ Reader \ Excel5.php

这是我的代码:

require_once 'Classes/PHPExcel/IOFactory.php';

$inputFileType = 'Excel5';
$inputFileName = '../public/mad/test_batch_solsys.xls';

$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcelReader = $objReader->load($inputFileName);

$loadedSheetNames = $objPHPExcelReader->getSheetNames();

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcelReader, 'CSV');

foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) {
    $objWriter->setSheetIndex($sheetIndex);
    $objWriter->save($loadedSheetName.'.csv');
}

0 个答案:

没有答案