Read only specific sheet

前端 未结 4 1425
面向向阳花
面向向阳花 2021-01-01 17:26

I am trying to read just one sheet from an xls document and I have this:

 $objPHPExcel = $objReader->load(\'daily/\' . $fisierInbound);
 $objWorksheet = $         


        
4条回答
  •  梦谈多话
    2021-01-01 18:09

    //load library - EXCEL
    $this->load->library('excel');
    $objPHPExcel = PHPExcel_IOFactory::load('./folder/exceldata.xls');
    

    Individual worksheets can be accessed by name, or by their index position in the workbook. The index position represents the order that each worksheet "tab" is shown when the workbook is opened in MS Excel (or other appropriate Spreadsheet program).

    To access a sheet by name, use the getSheetByName() method, specifying the name of the worksheet that you want to access.

    //Retrieve the worksheet called 'Worksheet 1'
    $objPHPExcel->getSheetByName('Worksheet 1');
    

    To access a sheet by its index, use the getSheet() method. Note that sheets are indexed from 0.

    //Retrieve the **1st 'tab' worksheet** e.g. called 'Sheet 1'
    $worksheet = $objPHPExcel->getSheet(0);
    //Retrieve the **2nd 'tab' worksheet** e.g. called 'Sheet 2'
    $worksheet = $objPHPExcel->getSheet(1);
    

    This all can be achieved by help of @Mark Baker 's PHPExcel Library. Thanks.

提交回复
热议问题