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

Hyperlinks not visible when viewing xlsx spreadsheet in Apple Numbers #4363

Closed
syntheticencounters opened this issue Feb 13, 2025 · 4 comments

Comments

@syntheticencounters
Copy link

syntheticencounters commented Feb 13, 2025

I've come across an unusual issue that I can't seem to find much information about. When adding hyperlinks to a spreadsheet, the links are present when viewing the document in Excel and Google Sheets but they are not present when viewing the document in Apple Numbers. I wanted to see if anyone has experienced this issue and if there was a recommended way to prepare a hyperlink for Apple Numbers. The version of PHPSpreadsheet that we are using is quite old but we are limited by the PHP version installed on our server. Please let me know if there's any other information that I can provide.

Here's how we are creating the hyperlink for each cell

public static function set_spreadsheet_urls($sheet = null, $d = []) {

    $column_address = $d['column_address'] ?? null;
    $should_skip_header_row = isset($d['should_skip_header_row']) ? boolval($d['should_skip_header_row']) : false;
    $url_formatter = $d['url_formatter'] ?? null;

    // loop through rows and determine next steps
    $rows = $sheet->getRowIterator();
    foreach($rows as $index => $row) {

        // skip header row if applicable
        if($should_skip_header_row === true && $index === 1) {
            continue;
        }

        // skip empty rows
        if($row->isEmpty() === true) {
            continue;
        }

        // prepare cell iterator for current row
        $iterator = $row->getCellIterator();
        $iterator->setIterateOnlyExistingCells(false);

        // loop through each cell for the current row and set url
        foreach($iterator as $address => $cell) {
            if($address === $column_address) {
                $url = $url_formatter($cell->getValue(), $index);
                $sheet->getCell("{$address}{$index}")->getHyperlink()->setUrl($url);
            }
        }
    }
}

PHPSpreadsheet: 1.17
Apple Numbers: 14.3

@oleibman
Copy link
Collaborator

I am sorry, I am not able to help with any unsupported versions. You will have to upgrade to at least PhpSpreadsheet 1.29.10, and Php 8.1 (in a pinch Php 7.4, but not for much longer).

@syntheticencounters
Copy link
Author

I am sorry, I am not able to help with any unsupported versions. You will have to upgrade to at least PhpSpreadsheet 1.29.10, and Php 8.1 (in a pinch Php 7.4, but not for much longer).

Thanks for the response. I installed 1.29.10 on my local machine and ran the application code. I found that cells containing at least one non-numeric value respected the hyperlink but cells containing only numbers did not respect the hyperlink. I ran the same test with 1.17 on our server and the behavior was the same as 1.29.10. Appending or prepending a space to the numeric values solves the issue but that unfortunately isn't a workable solution for our spreadsheet. Can you think of any reason why cells with only numbers aren't respecting the hyperlink?

@oleibman
Copy link
Collaborator

If you generate the spreadsheet using Excel (or Google Sheets exported to Excel), does the same problem happen? If it does, then I think you need to report the problem to Apple. If the Excel file works and the PhpSpreadsheet does not, can you upload them both here so that I can check what might be different?

@syntheticencounters
Copy link
Author

If you generate the spreadsheet using Excel (or Google Sheets exported to Excel), does the same problem happen? If it does, then I think you need to report the problem to Apple. If the Excel file works and the PhpSpreadsheet does not, can you upload them both here so that I can check what might be different?

Thanks for getting back with me. I created a test document with Google sheets containing a numeric cell and a non-numeric cell. Apple Numbers presented a hyperlink for the non-numeric cell but no hyperlink was present for the numeric cell. This looks to be an issue with Apple Numbers. Thanks for your help, I'll close this issue.

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