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

Clickable-url works in Xlsx not in Ods #3660

Closed
canonex opened this issue Jul 31, 2023 · 0 comments · Fixed by #3669
Closed

Clickable-url works in Xlsx not in Ods #3660

canonex opened this issue Jul 31, 2023 · 0 comments · Fixed by #3669

Comments

@canonex
Copy link

canonex commented Jul 31, 2023

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?

It is expected that the code suggested in:
change-a-cell-into-a-clickable-url
works the same across formats

What is the current behavior?

Doing:

$writer = new Xlsx($spreadsheet);
$writer->save('BUG.xlsx');

the Url in cell is correctly save

Doing:

$writerO = new Ods($spreadsheet);
$writerO->save('BUG.ods');

the cell is just text without Url

What are the steps to reproduce?

<?php

require __DIR__ . '/vendor/autoload.php';

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();


$activeWorksheet = $spreadsheet->getActiveSheet();
$activeWorksheet->setCellValue('A1', 'Hello World !');

$spreadsheet->getActiveSheet()->setCellValue('A2', 'http://example.org/');
$spreadsheet->getActiveSheet()->getCell('A2')->getHyperlink()->setUrl("http://example.org/");


$writer = new Xlsx($spreadsheet); 
$writer->save('BUG.xlsx'); //OK

$writerO = new Ods($spreadsheet);
$writerO->save('BUG.ods'); //MISSING URL

?>

Attached the results.

What features do you think are causing the issue

...cant say, I would check getHyperlink() or setUrl() output.

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

Ods is affected.
Attached the results files (Xlsx working and Ods not).
2023-07-31_19-23-53_BUG.ods
2023-07-31_19-23-53_BUG.xlsx

Which versions of PhpSpreadsheet and PHP are affected?

I have tested in PHP 8.1.12 and PhpSpreadsheet 1.29.0.

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Aug 8, 2023
Fix PHPOffice#3660. Code existed to read a hyperlink in a cell for Ods, but did not exist for writing. Hyperlinks pointing within a document use a different representation than for Excel (and therefore for PhpSpreadsheet); read and write will both handle the mapping from one to the other.

While researching how to write the text part of a started Xml element, it transpired that writing 2 Ods properties (Company and Category) did not escape their values properly. Confirmed and fixed problem. I do not believe that there is such an exposure for any other writer. As it turns out, Ods Reader was not processing Company or Category properly; that is fixed.
@oleibman oleibman mentioned this issue Aug 8, 2023
11 tasks
oleibman added a commit that referenced this issue Aug 12, 2023
Fix #3660. Code existed to read a hyperlink in a cell for Ods, but did not exist for writing. Hyperlinks pointing within a document use a different representation than for Excel (and therefore for PhpSpreadsheet); read and write will both handle the mapping from one to the other.

While researching how to write the text part of a started Xml element, it transpired that writing 2 Ods properties (Company and Category) did not escape their values properly. Confirmed and fixed problem. I do not believe that there is such an exposure for any other writer. As it turns out, Ods Reader was not processing Company or Category properly; that is fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant