PHPExcel toArray跳过第一行标题 [英] PHPExcel toArray skip first header row

查看:451
本文介绍了PHPExcel toArray跳过第一行标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一个excel文件上传到网站并进行处理以供数据库使用.

I'm uploading an excel file to website and process it for database use.

我正在使用toArray()函数来获取php数组中的所有行.

I'm using toArray() function to get all rows in a php array.

但是我想跳过第一行(标题行).其余的行将存储在数组中.

But I want to skip the first row ( header title row). The rest of rows will be stored in array.

如何跳过第一行.

注意:我不能使用rangeToArray()函数,因为没有固定的范围将行放入数组.它是动态的.我想要的就是获得除第一行外的所有行.

Note : I can't use rangeToArray() function since there is not fixed range to get rows into array. It is dynamic. All i want is get all rows except first.

推荐答案

Eko可以解决一半的问题,您可以使用rangeToArray();.但您根本不需要使用循环:

Eko answers half the problem, you can use rangeToArray(); but you don't need to use a loop at all:

$highestRow = $sheet->getHighestRow(); 
$highestColumn = $sheet->getHighestColumn();

$sheetData = $sheet->rangeToArray(
    'A2:' . $highestColumn . $highestRow,
    NULL,TRUE,FALSE
);

或者,使用toArray(),然后仅unset返回数组中的第一个元素

Alternatively, use toArray() and then just unset the first element from the returned array

这篇关于PHPExcel toArray跳过第一行标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆