Skip to content

External workbook name not in formula #4504

@Benny44

Description

@Benny44

I understand (from digging through the codebase) that a formula with a reference to a cell in an external workbook does not work. What I don't get, however, is why the name of the workbook is filtered out and replaced by a number. F.e. in the minimal working example below, I have set cell A1 in basic2 to refer to A1 in basic. This reads in excel as the following formula: =[basic.xlsx]Sheet1!$A$1. In PHP, however, I obtain =[1]Sheet1!$A$1 using the code below. Can someone tell me where this conversion is made and/or how I could retrieve the filename of the external workbook? This would help me, even though the calculation can not be run.

Interestingly, I noted that if I include a reference to another (different) workbook in basic2, this will be read as [2], so that is why I suspect a conversion between external workbook names and numbers is made at some point.

require '../vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;

$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$reader->setIgnoreRowsWithNoCells(true);
$reader->setReadDataOnly(true);

$spreadsheet = $reader->load("./basic2.xlsx");

$cell = $spreadsheet->getActiveSheet()->getCell("A1");

$cell->getStyle()->setQuotePrefix(false);
echo $cell->getValue() . "\n";

basic.xlsx
basic2.xlsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions