Skip to content

HYPERLINK function not working correctly when you try to link a cell to another spreadsheet #56

Closed
@DarkTiBe

Description

@DarkTiBe

When you set the content of a cell to =HYPERLINK("#anotherspreadshet!A1","link") the class throws the next Fatal error:


Uncaught exception 'PhpOffice\PhpSpreadsheet\Calculation\Exception' with message 'anotherspreadshet!A1 -> Formula Error: An unexpected error occured' in \src\PhpSpreadsheet\Cell.php:280
Stack trace:
#0 src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(1080): PhpOffice\PhpSpreadsheet\Cell->>getCalculatedValue()
#1 src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(1027): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeCell(Object(PhpOffice\PhpSpreadsheet\Shared\XMLWriter), Object(PhpOffice\PhpSpreadsheet\Worksheet), 'A1', Array, Array)
#2 src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(80): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeSheetData(Object(PhpOffice\PhpSpreadsheet\Shared\XMLWriter), Object(PhpOffice\PhpSpreadsheet\Worksheet), Array)
#3 srcl\PhpSpreadsheet\W src\Cell.php on line 280

Activity

changed the title [-]HYPERLINK function not working correctly when you try to link a cell on another spreadsheet[/-] [+]HYPERLINK function not working correctly when you try to link a cell to another spreadsheet[/+] on Dec 14, 2016
MarkBaker

MarkBaker commented on Dec 15, 2016

@MarkBaker
Member

Nasty, nasty Microsoft.... they changed the syntax for inter-sheet references between formats.

For xls, the syntax is sheet://anotherspreadshet!A1; for xlsx, they changed it to #anotherspreadshet!A1

Will need to take a closer look at handling this, and it's made more awkward by using it in a formula

added
writer/xlsxWriter for MS OfficeOpenXML-format (xlsx) spreadsheet files
on Apr 18, 2017
stale

stale commented on Dec 4, 2017

@stale

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

oleibman

oleibman commented on Apr 30, 2025

@oleibman
Collaborator

Sometime between 7-odd years ago when this issue was marked stale and now, it was resolved. It happened so long ago that I can't even point to specific fix. Oddly, however, the issue was reported against Xlsx, and the commentary suggests that Xls was behaving. However, it seems to me that Xls is not working correctly, so I am reopening the issue, to be closed when I submit a PR to fix it, which I will do shortly.

added a commit that references this issue on May 7, 2025
92d3c1b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    writer/xlsxWriter for MS OfficeOpenXML-format (xlsx) spreadsheet files

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @PowerKiKi@MarkBaker@oleibman@DarkTiBe

      Issue actions

        HYPERLINK function not working correctly when you try to link a cell to another spreadsheet · Issue #56 · PHPOffice/PhpSpreadsheet