我正在尝试将 Excel 2007 工作簿中的工作表导出到 csv 并将 csv 保存为工作表名称。我不断收到此错误:
"Object of class PHPExcel_Worksheet could not be converted to string in"
这是我的代码:
require_once '../Classes/PHPExcel/IOFactory.php';
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(false);
//$xlsxfiles=$_SESSION['file'];
//echo $xlsxfiles;
$objPHPExcel = $objReader->load('../upload/Demobook.xlsx');
$num=$objPHPExcel->getSheetCount() ;
$sheetnames=$objPHPExcel->getSheetNames() ;
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow(); // e.g. 10
$objWriter = new PHPExcel_Writer_CSV($objPHPExcel);
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet)
{
$worksheet->getTitle();
$objWriter->setDelimiter(',');
$objWriter->setEnclosure('');
$objWriter->setLineEnding("\r\n");
}
$objWriter->save("../"."CSV"."/".$worksheet.".".'csv');