-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Unable to save with setFormatCode in ODS, and getFormatCode from existing documents #3961
Comments
There is very limited support for reading most styles (getFormatCode) in Ods Reader, and it might take a lot of effort to add more. Although I don't see any support for Number Formats in Ods Writer (setFormatCode), it might be possible to add some. I'll be away a while, but I'll take a look when I get back. |
Then I am missing something here. The Features cross reference#writers say ODS has support for writing all sorts of Cell Formatting including Number Format Mask. The #reader table states ODS supports reading Number Format Mask. I have no problems setting font-name, font-size, font-weight, cell-alignment etc. Both for entire sheet and individual cells. The same Feature table say cell column-width / row-height is not supported for ODS, but those work fine as well. I am also using cell-merging without problem. What I use and that works fine with ODS:
The one thing not working (and the thing I of course implemented last hah) was cell-formatting. And this does not apply. Checking further; the last things that I had thought adding does not work either:
In conclusion I guess I use XLS(X) instead of ODS and convert the product to ODS locally, i.e:
As a note I believe it should state more clearly that ODS has limited support. As an anecdote my process was this: Have been using a hack where I create document templates as ODS in LibreOffice. Save them and unpack them. Then I have a PHP script that use this as base to create new documents. As this is both cumbersome and a product of an ad-hock solution I went looking for some library. Found this one where it says at top "PhpSpreadsheet is a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc." - OK, good, I thought. Went on to install it and start poking around. First test was the "Hello World!" from https://phpspreadsheet.readthedocs.io/en/latest/ . All good. Then changed to ODS. Still all good. Fired up the test-server and had a look around. All OK. Then started to write a simple wrapper class and filling in data poking around in the PhpSpreadsheet Documentation. All good. Then came to formatting and full stop. Searching the WWW. No fix. Trying various ways to set it and also set the data (as described in OP) no fix. Looking at the API docs. Nothing further. And so on ... at last ending up posting a ticket here. IMO perhaps some clear statement in both README and the front-page of the Documentation informing about the big feature differences between formats. I got the impression it was opaque to containers. I mean looking at this page: https://phpspreadsheet.readthedocs.io/en/latest/ I get the impression (First line of File formats supported) is ODS. Nothing about limitations. Further down in the Getting started section - still no notice about limitations etc. As the spreadsheet API is opaque to file-format and there is no errors or warnings when using calls that does not apply it is, was at least for me, easy to have blinders on that prevent one from understanding it is a container issue. And - yes, the Features cross reference says a lot of this, - but to be honest I jumped right into topics and did not register that table until after I posted OP. Not that it would have helped as from how I read it - it say it supports number formatting. As it say no on row/column dimensions I'd skip it though ... It is of course a likelihood it is all about me being a moron, but still. |
I am sorry that the experience has been so frustrating for you. As far as the documentation is concerned, I will look into the errors. But ... we do accept PRs, and, since you are obviously further ahead than I will be in what is wrong or not emphasized sufficiently, perhaps you would like to take a shot at correcting some of the doc problems with a PR. |
I do not mean to sound negative. It's an awesome project, was merely meant as some hints. As for PR I'll see what I find out when back after Easter. Would have to look closer at various aspects before deciding on a suggestion. |
This is:
What is the expected behavior?
Formatted numbers.
What is the current behavior?
No formatting.
What are the steps to reproduce?
Have also tried all kind of variants like
Have also tried all sorts of variants with numbers; as string, as int,as float, ...
If I do:
The correct format is dumped after applying. But never applied to the written file.
Have also tried to save a file with formatting using LibreOffice then reading it with PhpSpreadsheet - but the
var_dump(... getFormatCode());
only saystring(7) "General"
. Have also tried to scan 100x100 cells but no cell has any format.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?
The text was updated successfully, but these errors were encountered: