我正在使用大型 excel 文件,我已经删除了限制,有没有一种方法可以更快地阅读我的单元格。我有 6000 行并减少了我的 wamp 文件夹中的 tmp 文件夹。
set_time_limit(0);
ini_set('memory_limit', '-1');
include'../Classes/PHPExcel.php';
include'../Classes/PHPExcel/IOFactory.php';
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
$cacheSettings = array( ' memoryCacheSize ' =>'8MB');
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
$objReader = new PHPExcel_Reader_Excel2007();
$objPHPExcel = $objReader->load('Book1.xlsx');
$highestRowEM = $objPHPExcel->getActiveSheet()->getHighestRow();
echo $highestRowEM;
for($i=0;$i<$highestRowEM;$i++){
$varval=$objPHPExcel->getActiveSheet()->getCell('A'.$i)->getValue();
if($varval==""){
break;
}
}
echo $i;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('Book1.xlsx');
什么清理带有工作表的工作簿,其中
`include'../Classes/PHPExcel.php';
include'../Classes/PHPExcel/IOFactory.php';
set_time_limit(0);
ini_set('memory_limit', '-1');
$xlsxfiles=$_SESSION['file'];
echo $xlsxfiles;
echo "<br>";
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = PHPExcel_IOFactory::load('../upload/'.$xlsxfiles);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007");
////Validation
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
$highestRow = $worksheet-> getHighestDataRow();
$columnhighest=$worksheet->getHighestDataColumn();
$columnhighestval=array_search($columnhighest, $alphabet);
echo 'Worksheet - ' , $worksheet->getTitle()." Number of rows: ".$highestRow."<br>";
for($cl=0;$cl<$highestRow+1;$cl++){
for ($ga=1;$ga<$columnhighestval;$ga++){
$letters=strtoupper($alphabet[$ga]);
$clean=$worksheet->getCell($letters.$cl)->getValue();
$cleandone=str_replace(','," ",$clean);
$worksheet->setCellValue($letters.$cl,$cleandone);
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
}
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007");
$objWriter->setOffice2003Compatibility(true);
$objWriter->save('../upload/'.$xlsxfiles);
echo "Done";