Commit Graph

68 Commits

Author SHA1 Message Date
oleibman 97a80f383c
Improve HTML Writer (#1464)
There are a number of situations where HTML write was producing
HTML which could not be validated. These include:

  - inconsistent use of backslash terminating META, IMG, and COL tags
  - @page style tags in body rather than header. Aside from being
    non-standard, HTML Reader treats those as spreadsheet data.
  - <div style="page-break-before:always" />, a construct which is
    usually better handled through css anyhow.
  - no alt tag for images (drawings and charts)

Other problems:

  - Windows file names not handled correctly for images
  - Memory drawings not handled in extendRowsForChartsAndImages
  - No handling of different values for showing gridlines
    for screen and print
  - Mpdf and Dompdf do not require the use of inline css.
    Tcpdf remains a holdout in the use of this inferior approach.
  - no need to chunk base64 encoding of embedded images
  - support for colors in number format was buggy (html tags
    run through htmlspecialchars)

Code has been refactored when practical to reduce the number of
very large functions.

Coverage is now 100% for the entire HTML Writer module,
from 75% lines and 39% methods beforehand.

All functions dealing only with charts
are bypassed for coverage because the version of Jpgraph available in
Composer is not suitable for PHP7. The code will, nevertheless,
run successfully, but with warning messages. I have confirmed that
the code is entirely covered, without warnings, when the current
version of Jpgraph is used in lieu of the one available in Composer.
I will be glad to revisit this when the Jpgraph problem is resolved.

Directory PhpSpreadsheetTests/Writer/Html was created to house
the new tests. It seemed logical to move HtmlCommentsTest to
the new directory from PhpSpreadsheetTests/Functional.

A function to generate all the HTML is useful, especially for testing,
but also in lieu of the multiple other generate* functions. I have
added and documented generateHTMLAll.

The documentation for the generate* functions (a) produces invalid html,
(b) produces html which cannot be handled correctly by HTML reader,
and (c) even if those were correct, does not actually affect
the display of the spreadsheet. The documentation has been replaced
by a valid, and more instructive, example.

The (undocumented) useEmbeddedCss property, and the functions
to test and set it are no longer needed. Rather than breaking
existing code by deleting them, I marked the functions deprecated.

This change borrows a change to LocaleFloatsTest from
pull request 1456, submitted a little over a week before this one.


## Improve NumberFormat Support

First phase of this change included correcting NumberFormat handling
in HTML Writer. Certain complex formats could not be handled without
changes to Style/NumberFormat, and I did not wish to combine those changes.

Once the original change had been pushed, I took this part of it back up.
HTML Writer can now handle conditions in formats like:
[Blue][>=3000.5]$#,##0.00;[Red][<0]$#,##0.00;$#,##0.00
In testing, I discovered several errors and omissions
in handling of some other formats.
These are now corrected, and tests added.
2020-05-18 12:43:18 +09:00
oleibman 7517cdd008
Improve Coverage for CSV (#1475)
I believe that both CSV Reader and Writer are 100% covered now.

There were some errors uncovered during development.

The reader specifically permits encodings other than UTF-8 to be used.
However, fgetcsv will not properly handle other encodings.
I tried replacing it with fgets/iconv/strgetcsv, but that could not
handle line breaks within a cell, even for UTF-8.
This is, I'm sure, a very rare use case.
I eventually handled it by using php://memory to hold the translated
file contents for non-UTF8. There were no tests for this situation,
and now there are (probably too many).

"Contiguous" read was not handle correctly. There is a file
in samples which uses it. It was designed to read a large sheet,
and split it into three. The first sheet was corrrect, but the
second and third were almost entirely empty. This has been corrected,
and the sample code was adapted into a formal test with assertions
to confirm that it works as designed.

I made a minor documentation change. Unlike HTML, where you never
need a BOM because you can declare the encoding in the file,
a CSV with non-ASCII characters must explicitly include a BOM
for Excel to handle it correctly. This was explained in the Reading CSV
section, but was glossed over in the Writing CSV section, which I
have updated.
2020-05-17 18:15:18 +09:00
Adrien Crivelli 588ca6beb3
Replace migration tool with RectorPHP
Fixes #1445
2020-05-02 12:34:50 +09:00
Adrien Crivelli 57c36e01d5
Replace Sami with phpDocumentor 3
Because Sami is deprecated and now raise errors. We lose API
docs for multiple versions but we still have latest version with low
maintenance cost.
2020-04-05 17:47:25 +09:00
Marius 50d78ce789 update doc on how to run the migrate tool
as per this https://stackoverflow.com/questions/53215313/phpspreadsheet-how-do-i-use-auto-migration-tool clarify how to run the tool
2020-03-07 09:20:30 +07:00
Nathanael d. Noblet 22bf54ca11 Allow Html Reader to write into existing spreadsheet
Sometimes you may want to read html into multiple worksheets within one
spreadsheet. Allowing the passing of a spreadsheet in makes this possible.
2019-11-17 21:17:56 +01:00
Claudio Galdiolo 74bc0b826d reword repeated text 2019-08-17 13:49:27 -07:00
Nathanael Noblet 95c8bb9918
Allow HTML Reader to load from string
We often want to export a table as an excel sheet. The system renders the
html and it seems like a waste of time to write it to the file system to
use the reader. This allows us to render the html and then just pass it to
a reader

Closes #1136
2019-08-17 12:54:22 -07:00
MarkBaker 38e71a1210 Fix Documentation type 2019-07-09 19:39:12 +02:00
Gowrav Vishwakarma ca56fd258c Typo (#1007)
Cell B5 is about to get the changs btw
2019-06-14 08:32:19 +02:00
Mark Baker c9dc1e6130
String value binder (#901)
* Document calculation caching; and how to disable it and how to flush the cache

* Quoted text for string values beginning with `=`, so that they are still treated as strings and not as formulae

* Warning about assigning cells to variables

* Further warning about assigning cells to variables

* getCell() with a second argument

* Added String Value Binder, and a Reader example demonstrating how to use it

* Ensure value is a string before binding

* Sample file for String Value Binder

* PHPCS moaning about order or use statements

* Order of annotations, that PHPStorm determined, isn't what phpcs says it should be
2019-02-23 18:40:07 +01:00
Mark Baker 58a5172b8f
Document Improvements … (#899)
* Document calculation caching; and how to disable it and how to flush the cache

* Quoted text for string values beginning with `=`, so that they are still treated as strings and not as formulae

* Warning about assigning cells to variables

* Further warning about assigning cells to variables
2019-02-23 10:22:18 +01:00
Jon Dufresne 5b3870c508
Prefer https:// URLs when available in docs & comments
Fixes #737
2018-10-28 13:55:00 +11:00
Jon Dufresne f5c800c360 Correct typo: "they are" -> "there are" (#725) 2018-10-21 18:28:39 +11:00
Phil Taylor a98d885830 Typo (#652)
environnement = environment
2018-09-28 20:57:30 +09:00
Adrien Crivelli 57a0297011
HTML entities should not be escaped in Markdown 2018-07-24 10:13:58 +09:00
Adrien Crivelli ab541b9b5f
Emphasis the point being discussed 2018-06-04 14:09:21 +09:00
Adrien Crivelli 1afba78f85
Publish API documentation via Travis and Sami
Fixes #491
Fixes #497
2018-06-04 13:18:39 +09:00
werraco df6443feaf Update worksheets.md (#520)
Passing 0 arguments will throw the following error:
"PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function PhpOffice\PhpSpreadsheet\Spreadsheet::getSheet(), 0 passed in {filepath} and exactly 1 expected"
2018-05-31 20:30:04 +09:00
netpassprod1 52ff262ddb Add notes for the Timezone functions in Date class (#431)
The \PhpOffice\PhpSpreadsheet\Shared\Date class has support for setting an alternate timezone which affects the conversion of Excel Date timestamps in PhpSpreadsheet. This amendment is an effort to document this support.
2018-03-22 10:51:29 +09:00
Adrien Crivelli 46a2c4106a
Fix recently refactored class name in docs 2018-03-19 18:19:55 +09:00
Paul Klimov eb612157dd array short syntax in documentaiton (#373) 2018-02-25 13:16:04 +01:00
Adrien Crivelli 8aef9d10a3
Mentions removed default values in migration guide
Closes #360
2018-02-11 16:24:14 +09:00
Adrien Crivelli 28d827d569
Missing backticks 2018-01-17 12:10:12 +09:00
Gedas Lukošius 55689caa1d Change array key from style to borderStyle 2018-01-09 00:45:19 +09:00
Adrien Crivelli 98e0a97139
Typo in documentation
Closes #315
2018-01-04 13:34:25 +09:00
Gabriel Caruso bae2348fc9 Remove extra lines
Signed-off-by: Gabriel Caruso <carusogabriel34@gmail.com>
2017-12-31 22:04:01 +09:00
Gabriel Caruso ae5fadff56 Trailing whitespaces
Signed-off-by: Gabriel Caruso <carusogabriel34@gmail.com>
2017-12-31 22:04:01 +09:00
Adrien Crivelli c46008b2be
Quote class names in docs 2017-12-30 19:44:32 +09:00
Adrien Crivelli 4dd486fb94
Clean up very obsolete links 2017-12-30 19:07:22 +09:00
Adrien Crivelli fff3630780
Support migration of prefixed classes 2017-12-25 10:49:14 +09:00
Adrien Crivelli d383bc356c
Restore reference to calculation engine 2017-12-20 00:20:38 +09:00
Adrien Crivelli cfcafd3e73
Typo in docs 2017-12-20 00:20:38 +09:00
Terje Bråten 8288a7f029 Documentation change for column indexing 2017-12-19 12:07:19 +09:00
Adrien Crivelli 67767e1402
Incorrect class in documentation 2017-12-17 23:11:25 +09:00
Adrien Crivelli 341e82f6eb
Line ending is detected automatically since commit f2310e05d
Closes #293
2017-12-17 16:49:37 +09:00
Adrien Crivelli 8d76020590
Consistent `stringFromColumnIndex()` and `columnIndexFromString()`
Column indexes are always based on 1 everywhere in PhpSpreadsheet.
This is consistent with rows starting at 1, as well as Excel
function `COLUMN()`. It should also make it easier to reason about
columns and rows and remove any doubts whether a specific method is
expecting 0 based or 1 based indexes.

Fixes #273
Fixes https://github.com/PHPOffice/PHPExcel/issues/307
Fixes https://github.com/PHPOffice/PHPExcel/issues/476
2017-11-26 15:29:08 +09:00
Maxim Bulygin 442e612202
Support custom PDF library instances or configurations
This allow to create and configure the standard instance of the
external PDF libary, before returning it to the standard writer.

Or, more powerful, this allow to provide a custom implementation
of the external PDF library, allowing for custom behaviors. An
example of that would something like: https://tcpdf.org/examples/example_003/

Closes #266
2017-11-04 16:01:09 +09:00
Adrien Crivelli 888c618227
Fix typo 2017-10-30 11:37:24 +09:00
Adrien Crivelli 557e80dc03
Rename classes to keep them in their related namespaces 2017-10-29 17:39:42 +09:00
Adrien Crivelli 782b4e4fae
Upgrade chart rendering support to be composer based
This allow to get rid of manual class loading and have simpler
usage of the library.
2017-10-29 01:58:42 +09:00
Adrien Crivelli 25ff914aa6
Simplify IOFactory to rely on autoloading 2017-10-22 01:54:14 +09:00
mosa ee700f7c7d change array_push() to $array[] (#254)
http://php.net/manual/en/function.array-push.php#refsect1-function.array-push-description

> Note: If you use array_push() to add one element to the array it's better to use $array[] = because in that way there is no overhead of calling a function.
2017-10-19 11:07:31 +09:00
Adrien Crivelli b3e6538066
Document readers/writeres short name changes
Closes #253
2017-10-17 16:16:54 +09:00
Adrien Crivelli 79ab852bf5
Expose PDF writer to be used directly
We used to have some kind of wrapper that didn't do much except
forward methods to the real instance. That unnecessary complexity
made it harder to work with the real writer instance.
2017-10-14 14:57:44 +09:00
gdbonino 0bccbca031 Update worksheets.md (#243) 2017-10-10 16:14:19 +09:00
Adrien Crivelli bd3285b4fa
Avoid underscore in property names 2017-10-08 14:37:11 +09:00
Adrien Crivelli 50a0ec58af
Merge all examples together
Closes #17
2017-10-01 17:48:59 +09:00
Adrien Crivelli 5e15abc60a
Clarify doc about security 2017-09-09 03:16:47 +09:00
Adrien Crivelli 1c5db4e170
Standardize keys used for styling
Array keys used for styling have been standardized for a more coherent experience.
It now uses the same wording and casing as the getter and setter methods.

Closes #189
2017-09-09 02:56:23 +09:00