以下代码将XLS文件的每个工作表转换为CSV文件。但我找不到办法阻止它将XLS中的空白行包含在CSV中。
请帮帮我。
function convertXLStoCSV($infile, $outfile) // the function that converts the file
{
$fileType = PHPExcel_IOFactory::identify($infile);
$objReader = PHPExcel_IOFactory::createReader($fileType);
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($infile);
$writer = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
$writer->setDelimiter(",");
$writer->setEnclosure("");
foreach ($objPHPExcel->getWorksheetIterator() as $workSheetIndex => $worksheet)
{
$objPHPExcel->setActiveSheetIndex($workSheetIndex);
$writer->setSheetIndex($workSheetIndex);
$writer->save('converted/' . $outfile ."_" . $worksheet->getTitle() . ".csv");
echo $outfile;
echo $infile;
}
}