-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Chart title loses reference to cell #3797
Comments
Thank you for the sample file. PhpSpreadsheet does not support using a formula for a title. I will investigate whether it can be supported. |
Excel doesn't either - that's why I have the formula in another cell and reference that. Excel does support that. |
Excel stores the cell references as if they were formulas. I agree that, at least at present, Excel restricts the formulas to references to a single cell (and sheet name must be part of the reference). I'm not sure that's a safe long-term assumption (but it probably is). Your example sheet pointed out something else missing from PhpSpreadsheet. Your title font specifies all-caps, which is not an attribute that you can apply to a font for a cell. I'll have to see if it can be supported. |
So is there - currently - a way of setting a chart's title using PhpSpreadsheet? |
Yes, the chart has a Title object, which has a caption property. Most of the 33* members in samples/Chart do this. What you can't do yet is make the title dynamic, which is the issue you raised. |
Fix PHPOffice#3797. Excel allows a Chart Title to be a formula, albeit a very rigidly limited one. It can only be a reference to a single cell, and the worksheet name must be specified, and the column and row must be absolute. Methods are added to Chart/Title to accommodate this (and styling for it). This will be handled for input/output for Xlsx, and for output for Html. The sample file which was submitted with this issue demonstrated that something else was missing. When setting the font for a chart title in Excel, you can specify all-caps or small-caps, options not available for most cell formatting. These are now added. The sample file also fell into the category of spreadsheets which lose one or more charts when converted to Html. I have redone the "extend rows and charts" logic in Html Writer. It is now clearer (I hope) and more efficient, and hopefully this problem will not arise again.
* Chart Dynamic Title and Special Font Properties Fix #3797. Excel allows a Chart Title to be a formula, albeit a very rigidly limited one. It can only be a reference to a single cell, and the worksheet name must be specified, and the column and row must be absolute. Methods are added to Chart/Title to accommodate this (and styling for it). This will be handled for input/output for Xlsx, and for output for Html. The sample file which was submitted with this issue demonstrated that something else was missing. When setting the font for a chart title in Excel, you can specify all-caps or small-caps, options not available for most cell formatting. These are now added. The sample file also fell into the category of spreadsheets which lose one or more charts when converted to Html. I have redone the "extend rows and charts" logic in Html Writer. It is now clearer (I hope) and more efficient, and hopefully this problem will not arise again. * Scrutinizer 50/50 One false positive, one correct "unused parameter".
This is:
What is the expected behavior?
If I have a graph title that relates to a cell, this should stay as is. I.e. the graph title's value is "=A1", deriving the value from Cell A1.
What is the current behavior?
When the graph has gone through the reader and writer, the output does have the correct data, i.e. the value of A1, but it is not a reference to A1 anymore.
What are the steps to reproduce?
Here is the sample Excel file that I use:
test-rotated_xlabel.xlsx
What features do you think are causing the issue
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Which versions of PhpSpreadsheet and PHP are affected?
PHP 8.1
The text was updated successfully, but these errors were encountered: