简体   繁体   中英

how to load first n rows from a scv file with phpexcel?

I haven't seen an example on loading the first n rows from afile

So far I have:

$objPHPExcel = PHPExcel_IOFactory::load($file_name);
$sheetData   = $objPHPExcel->getActiveSheet()->toArray(NULL, FALSE, TRUE, FALSE);

The reason I want to load only a few rows is that my file is large (10.000 entries) and im thinking that loading a few rows will be faster.

Any ideas?

If you want to load only a few rows, then use a read filter (as described in section 5.3 of the reader documentation , entitled Reading Only Specific Columns and Rows from a File (Read Filters) ).

If you've already loaded the file and only want to extract a few rows as an array into $sheetdata, then use rangeToArray() instead of toArray()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM