How to validate the number of columns to import PhpExcel?

0

Good morning,

Can someone please explain or tell me how to do it so that they do not let me import files that are passed or have fewer columns than the established ones?

Let's say if my table where I'm going to import has 8 columns from the A-H, validate if the file I'm importing has 8 columns if the file is passed or less does not matter.

Thanks in advance.

    
asked by Kygo 05.01.2018 в 21:11
source

1 answer

1

I do not fully understand your question, I'm going to assume that you mean uploading an Excel file to PHP and dealing with the PHPExcel library. If that were the case you can get the number of Columns with:

$objPHPExcel->setActiveSheetIndex(0)->getHighestColumn();

Or the number of rows with

$objPHPExcel->setActiveSheetIndex(0)->getHighestRow();

You can even get the dimensions of the sheet with:

$objPHPExcel->setActiveSheetIndex(0)->calculateWorksheetDimension();

The latter will return a range of cells.

    
answered by 05.01.2018 в 21:31