-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
This is:
- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
What is the expected behavior?
You can read sheetData by this.
public function getSheetData($sheetName)
{
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$spreadsheet = $reader->load("/var/www/storage/app/upload_file.xlsx");
$sheetData = $spreadsheet->getSheetByName($sheetName)->toArray();
return $sheetData;
}
What is the current behavior?
ErrorException (E_ERROR)
sheet!A2 -> Formula Error: Unexpected
What are the steps to reproduce?
A2
=SWITCH(B2,0,"ja",1,"en",2,"cs",3,"ko",4,"vi")
B2
=2
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
<?php
namespace App\Http\Controllers;
class ReadController
{
private $spreadsheet = array();
public function __construct()
{
$this->read();
}
private function read()
{
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$this->spreadsheet = $reader->load("/var/www/storage/app/upload_file.xlsx");
}
public function getSheetData($sheetName)
{
//error at this code
$sheetData = $this->spreadsheet->getSheetByName($sheetName)->toArray();
return $sheetData;
}
Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet - latest
PHP - 7.2
Laravel - 5.7
Metadata
Metadata
Assignees
Labels
No labels