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

Named Ranges - Support Formulas #1440

Closed
dericlima opened this issue Apr 11, 2020 · 7 comments
Closed

Named Ranges - Support Formulas #1440

dericlima opened this issue Apr 11, 2020 · 7 comments
Assignees
Labels
calculation engine enhancement reader/gnumeric Reader for Gnumeric spreadsheet files reader/numbers Reader for Apple Numbers spreadsheet files reader/ods Reader for Open/LibreOffice spreadsheet files (OASIS) reader/xls Reader for MS BIFF-format (xls) spreadsheet files reader/xlsx Reader for MS OfficeOpenXML-format (xlsx) spreadsheet files writer/gnumeric Writer for Gnumeric spreadsheet files writer/numbers Writer for Apple Numbers spreadsheet files writer/ods Writer for Open/LibreOffice spreadsheet files (OASIS) writer/xls Writer for MS BIFF-format (xls) spreadsheet files writer/xlsx Writer for MS OfficeOpenXML-format (xlsx) spreadsheet files

Comments

@dericlima
Copy link

dericlima commented Apr 11, 2020

This is:

- [x] a feature request

What is the expected behavior?

Creation of a named range that will contain a formula

What is the current behavior?

Formulas aren't supported in named ranges

What are the steps to reproduce?

Create a excel with a named range that contains a formula.

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

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

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

$spreadsheet->createSheet();
$spreadsheet->getActiveSheet()->fromArray(
    ['Prod A', 'Prod B', 'Prod C', 'Prod D', 'Prod E'],
    null,
    'A1'
);$spreadsheet->getActiveSheet()->fromArray(
    [1, 2, 3, 4, 5],
    null,
    'A2'
);
$spreadsheet->addNamedRange(new NamedRange('sumProducts', $spreadsheet->getActiveSheet(), '=SUM(A2:E2)'));

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

Which versions of PhpSpreadsheet and PHP are affected?

PHPSpreadsheet 1.9.0
PHP 7.2.24

@stale
Copy link

stale bot commented Jun 10, 2020

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.

@stale stale bot added the stale label Jun 10, 2020
@MarkBaker MarkBaker removed the stale label Jun 10, 2020
@MarkBaker MarkBaker self-assigned this Jun 10, 2020
@MarkBaker
Copy link
Member

This is currently work in progress, but it is a fairly major piece of code change, so it may well still take a month or so of work

@dericlima
Copy link
Author

@MarkBaker I tried to solve this on my own but without a full solution yet. I'm glad to help if I can....

@MarkBaker
Copy link
Member

Perhaps once the branch is more stable and I push it to the repo here. At the moment,it's still very much prototyping code to prove the principle, but it's a fairly major redesign of how defined names are handled, and it will take me a week or two before I'm satisfied enough to create a WIP PR.

Once there, I'll be happy if you want to do some testing against that branch.

@MarkBaker
Copy link
Member

You might want to take look at Merge Request #1535 and run some tests; it should provide pretty comprehensive coverage of named formulae, plus a lot of improvements and fixes for the handling of name ranges as well. There are still some cases that aren't covered; but it's pretty comprehensive... have a read of the notes and documentation as well

@MarkBaker MarkBaker added calculation engine reader/gnumeric Reader for Gnumeric spreadsheet files reader/numbers Reader for Apple Numbers spreadsheet files reader/ods Reader for Open/LibreOffice spreadsheet files (OASIS) reader/xls Reader for MS BIFF-format (xls) spreadsheet files reader/xlsx Reader for MS OfficeOpenXML-format (xlsx) spreadsheet files writer/gnumeric Writer for Gnumeric spreadsheet files writer/numbers Writer for Apple Numbers spreadsheet files writer/ods Writer for Open/LibreOffice spreadsheet files (OASIS) writer/xls Writer for MS BIFF-format (xls) spreadsheet files writer/xlsx Writer for MS OfficeOpenXML-format (xlsx) spreadsheet files enhancement labels Jul 15, 2020
@dericlima
Copy link
Author

@MarkBaker Thanks for this!! It's working like a charm. Feel free to close this issue

@stale
Copy link

stale bot commented Oct 4, 2020

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.

@stale stale bot added the stale label Oct 4, 2020
@oleibman oleibman removed the stale label Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
calculation engine enhancement reader/gnumeric Reader for Gnumeric spreadsheet files reader/numbers Reader for Apple Numbers spreadsheet files reader/ods Reader for Open/LibreOffice spreadsheet files (OASIS) reader/xls Reader for MS BIFF-format (xls) spreadsheet files reader/xlsx Reader for MS OfficeOpenXML-format (xlsx) spreadsheet files writer/gnumeric Writer for Gnumeric spreadsheet files writer/numbers Writer for Apple Numbers spreadsheet files writer/ods Writer for Open/LibreOffice spreadsheet files (OASIS) writer/xls Writer for MS BIFF-format (xls) spreadsheet files writer/xlsx Writer for MS OfficeOpenXML-format (xlsx) spreadsheet files
Development

No branches or pull requests

3 participants