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

More work to do in XML reader #3568

Closed
SlowFox71 opened this issue May 15, 2023 · 11 comments · Fixed by #3567
Closed

More work to do in XML reader #3568

SlowFox71 opened this issue May 15, 2023 · 11 comments · Fixed by #3567

Comments

@SlowFox71
Copy link

This is:

- [ ] a bug report
- [ X] a feature request
- [ X] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

After submitting #3566 I realized that there is a bunch of other options not yet implemented as well. (I generate XML-spreadsheets from templates, but now want to deliver xlsx-files upon user request; the templates should stay due to their convenience).

So far I integrated:

ExcelWorkbook/ActiveSheet,
Worksheet[Protected],
Column[Span],
Worksheet/WorksheetOptions/TopRowBottomPane,
Worksheet/WorksheetOptions/LeftColumnRightPane,
Style/Protection
and fixed a bug with Style/Font[bold] and Style/Font[Italic],

but there is more work to do, and often I do not know how to get the desired behavior in PhpSpreadsheet. My reference is http://m8y.org/Microsoft_Office_2003_XML_Reference_Schemas/Help/html/spreadsheetml_HV01151864.htm, and I try to integrate at least everything I am using. How could we proceed here - I'd need someone familiar with PhpSpreadsheet which I am definitely not.

@SlowFox71 SlowFox71 reopened this May 15, 2023
@oleibman
Copy link
Collaborator

You can start by identifying what you think is missing/buggy. I think you can just add it to this ticket or 3566. Sample spreadsheet(s) demonstrating the problems would be especially helpful.

@SlowFox71
Copy link
Author

SlowFox71 commented May 15, 2023

Ok, let's start with two bugs:
In Reader/Xml/Style/Font.php this

$style['font']['bold'] = true;

IMO should be

$style['font']['bold'] = ($styleAttributeValue == '1');

because the attribute is allowed to be 0 (even though Excel normally would not generate that). Same thing for italic of course.

oleibman - Fixed in most recent push.

@SlowFox71
Copy link
Author

SlowFox71 commented May 15, 2023

ExcelWorkbook/ActiveSheet should make the respective sheet active (starting with 0). I achieved this by reading the value first and using:

$spreadsheet->setActiveSheetIndex($activeSheet);

after all the sheets are there.
test.txt

oleibman - fixed in most recent push.

@SlowFox71
Copy link
Author

SlowFox71 commented May 15, 2023

Worksheet[Protected] is used to protect the worksheet (unless overwritten by specific styles). This seems to be what

$spreadsheet->getActiveSheet()->getProtection()->setSheet(true);

is doing.
test.txt

oleibman - included in latest push.

@SlowFox71
Copy link
Author

SlowFox71 commented May 15, 2023

Column[Span] is used to define a bunch of columns at once (1 for 1+1=2
columns). This can be easily implemented by iterating the column definition.
test.txt

oleibman - fixed in latest push.

@SlowFox71
Copy link
Author

SlowFox71 commented May 15, 2023

Style/Protection is used to protect and/or hide formulas. This corresponds 1:1 to the mechanism defined in Style/Protection::locked and Style/Protection::hidden.
test.txt

oleibman - fixed in latest push.

@SlowFox71
Copy link
Author

SlowFox71 commented May 15, 2023

WorksheetOptions/TopRowVisible and WorksheetOptions/LeftColumnVisible define the top-left position when the sheet is opened (0-based). I could not find a method to achieve this in PhpSpreadsheet yet.
test.txt

oleibman - This is now supported in latest push.

@SlowFox71
Copy link
Author

SlowFox71 commented May 15, 2023

WorksheetOptions/SplitHorizontal
WorksheetOptions/SplitVertial
WorksheetOptions/LeftColumnRightPane
WorksheetOptions/TopRowBottomPane
WorksheetOptions/ActivePane

These control a split display, but they require the presence of FreezePanes and FrozenNoSplit, which I am not totally sure about; they might refer to split modes and menu items no longer present in modern Excel.

ActivePane selects the active pane when the sheet is opened; the numbering is odd and explained in http://m8y.org/Microsoft_Office_2003_XML_Reference_Schemas/Help/html/spreadsheetml_HV01151864.htm

I don't really understand the Panes-section; I added it just as a reference what else might be possible here.

test.txt

@oleibman
Copy link
Collaborator

You missed the setting of selected cells for each worksheet. I have added that in the latest push. I will not be adding SplitHorizontal and its 4 associated items to my PR; it will need a lot more research. Please open a new issue if you wish to proceed with them. There are still a couple of items I have not yet addressed in those tickets. I'll decide tomorrow if I want to bundle those with what I've already changed, or if they will require a separate issue.

@SlowFox71
Copy link
Author

This is far more - and faster - than I dared to think of.

I am using SplitHorizontal in my sheets quite often, but I'll have another look at that myself first. There are even more interesting things (DataValidation), but lets make one step after the other.

@oleibman
Copy link
Collaborator

oleibman commented May 16, 2023

I think my PR is now in its final state. Please open a separate ticket for Column Span. I don't really understand what it's trying to accomplish. I think the fact that your example hides the spanned columns is at least in part responsible for my lack of understanding. Please give an example (in the new ticket) which shows everything and which doesn't use protection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants