1

制限を削除した大きな 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";
4

1 に答える 1