PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, October 5, 2022

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

 October 05, 2022     file-io, file-upload, php, phpexcel     No comments   

Issue

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?


Solution

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()



Answered By - Mark Baker
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing