Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't work $sheetData->toArray() if the .xlsx file sheet contains SWITCH() #963

Closed
azuma560 opened this issue Apr 16, 2019 · 1 comment
Closed

Comments

@azuma560
Copy link

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

@azuma560 azuma560 changed the title Can't $sheetData->toArray() if the .xlsx file sheet contains SWITCH() Can't work $sheetData->toArray() if the .xlsx file sheet contains SWITCH() Apr 16, 2019
@MarkBaker
Copy link
Member

PR merged into master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants