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
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
Previously the function did not check whether the return value of `ZipArchive::locateName`
was `false`. And when it was, it was passed straight into `ZipArchive::getFromIndex`,
which casts it to an integer, resulting in it incorrectly retrieving the entry at index `0`.
Fixes#262Closes#268
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.
Temporary directory set to PDF writer is passed to mPDF object in constructor.
mPDF 7.0 changed temporary directory configuration from constant to constructor parameter.
Without this change it is not possible to change default temporary directory.
See: https://mpdf.github.io/installation-setup/folders-for-temporary-files.html
Because it is a budren to maintain and LGPL 2.1 does not require
them, but only suggest them:
> To apply these terms, attach the following notices to the library.
> It is **safest** to attach them to the start of each source file
> to most effectively convey the exclusion of warranty; and each
> file **should** have at least the "copyright" line and a pointer
> to where the full notice is found.
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html#SEC4
When describing a cell, the cell reference (r="A1") is optional.
When not present, we should just increment the index of the last processed row.
Fixes#201Closes#225
When the xml file is not a standard xml file, the `simplexml_load_string` will return false, this will cause an error on "$xml->getNamespaces(true);" . So instead of showing the error, we throw an exception.
Control characters in cell values are automatically escaped without
the need to excplicitly call `StringHelper::buildCharacterSets()` beforehand.
Fixes#212
The static variable $imageCounter previously had a constant value of 0 throughout the program as it was never being modified, because it was commented out by mistake.
Now it increments every time a new drawing is being instantiated.
This also fixed a problem when multiple images of same name in the same worksheet are incorrectly displayed.
Fixes#204Closes#205
As described in http://interoperability.blob.core.windows.net/files/MS-XLS/[MS-XLS].pdf
a relative column reference can be between -255 +255 and not -127 + 127, the column
index should be read as a signed int16.
References:
- 2.2.2.2.1 Value Class / page 81
- 2.5.198.88 PtgRefN / page 815
- 2.5.198.111 RgceLocRel / page 828
Fixes#211Closes#214
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
Add option to suppress validation of sheet titles
Based on a "lowest common denominator" approach to compatibility,
we will continue to enforce a 31-character limit for sheet titles.
However, this limit should not be enforced when loading an existing
file.
Added a new optional parameter to Worksheet::setTitle() and
Worksheet::setCodeName() to suppress validation and massaging,
based on the premise that existing files should be given a
best-effort approach to loading and parsing. Unfortunately, it's
not possible with the current architecture to prevent users from
making use of this functionality, aside from with a strongly-worded
warning.
Added test coverage. I didn't see any existing unit tests of the
Worksheet class, so I created a new test to cover these methods.
Fixes#176
Fixes the PHP 7.1 bug reported over at PHPOffice/PHPExcel#1110
The behavior should not change since the default value used should behave the same way as the string value in earlier PHP versions.
Fixes a return type in the doc block of IReader.
Closes#165
We used to type hint against IWriter for writer part parent, but this
was not respected in writer part who often coded against the implementation
instead of the interface. With this change we make it a requirement for
writer parts to use their respective writer implementation instead of an
interface. This give legitimate access to all `BaseWriter` methods amongst
other things.
Having default values made it harder for end-user to figure out whether
it the arguement had to be supplied or not. Ommitting the argument may
lead to hard to debug issues, and is overall not a good idea.
Closes#110
In some exotic environnement (IBM AIX) it may happens that `//TRANSLIT` is not supported. In that case iconv would return false. We can easily identify the case and fallback on mbstring instead. That should give correct result.
Closes#135Closes#136
This is a hard limit of the BIFF format that cannot be worked around,
so it is best to throw exceptions than silently discard data or generate
corrupted files.
This drop a lot of non-core features code and delegate their maintainance
to third parties. Also it open the door to any missing implementation
out of the box, such as Redis for the moment.
Finally this consistently enforce a constraint where there can be one and
only one active cell at any point in time in code. This used to be true for
non-default implementation of cache, but it was not true for default
implementation where all cells were kept in-memory and thus were never
detached from their worksheet and thus were all kept functionnal at any
point in time.
This inconsistency of behavior between in-memory and off-memory could
lead to bugs when changing cache system if the end-user code was badly
written. Now end-user will never be able to write buggy code in the first
place, avoiding future headache when introducing caching.
Closes#3
We use to write the wrong property to file, leading to a warning
in PHP 7.1 since the `switch` never matched anything and the variable
was left as a string instead of as an int.
Closes https://github.com/PHPOffice/PHPExcel/issues/1110
Removed "unescape enclosure functionality", since the unescaping is already handled by fgetcsv,
and performing the unescaping again would actually result int the text from the cell being read wrong.
As an example try parsing the folowing CSV:
```
"<img alt="""" src=""http://example.com/image.jpg"" />"
```
With the additional unescaping it would have ended up as:
```
<img alt=" src="http://example.com/image.jpg" />
```
instead of the correct:
```
<img alt="" src="http://example.com/image.jpg" />
```
Fixes https://github.com/PHPOffice/PHPExcel/pull/1171
Settings: deleted libxml_disable_entity_loader() calls since they're not necessary.
Prevent setLibXmlLoaderOptions() and getLibXmlLoaderOptions() to call the libxml_disable_entity_loader() function which alter the global state of libxml.
See the discussion here https://github.com/PHPOffice/PhpSpreadsheet/issues/74
Those were deprecated a long time ago in 59932b0cac
but their replacement seems to have never been added. 5 years later the
best solution is to un-deprecate them and if someday their replacement are
actually added, then we can re-deprecate them properly.
Closes#22
Over the years PclZip became a maintenance problem. It's code base
is old and the official project seems to have died out. ZipArchive
is now more commonly available and offer an easier and more complete
API. So PclZip was dropped in order to focus our efforts on what matters.
Closes#18
We need to make note of two things:
- The old code was trying to clone an objectArray, and hence was performing a shallow copy of memoryDrawing objects (the __clone magic function was not getting invoked).
Instead, if one loops over the objectArray, and then clones the individual memory drawing objects, then the __clone function for the MemoryDrawing object is invoked.
- The __clone function for memory drawing was using the clone keyword which does not deal with circular references (Since memoryDrawing object had references to worksheet object, it was encountering an infinite loop). However, serializing and unserializing objects deals with circular references pretty well.
Fixes#92Closes#106
By design, UTF-8 allows any byte-oriented substring searching algorithm,
since the sequence of bytes for a character cannot occur anywhere else
([source](https://en.wikipedia.org/wiki/UTF-8#Advantages_3)).
So `str_replace()` also works for UTF-8-encoded strings, assuming that
the input strings are valid UTF-8 strings. The previous implementation
of mbStrReplace() did nothing to detect invalid strings.
Also, `str_replace()` does not support [Unicode equivalence](https://en.wikipedia.org/wiki/Unicode_equivalence),
but nor do the other `mb_string` functions, and nor does `=SUBSTITUTE()` in Excel
(tested on Excel for Mac version 15.19.1, Excel 2016 for Windows and LibreOffice 5.1).
Closes#109
Because alignment was all broken and becaues it doesn't improve much
the code readability, but potentially create more complicated diff, we
prefer to unlaign all docblocks.
Third party PDF libraries must now be installed via composer and naturally
via composer autoloading mechanism. Because of that it is not necessary
to specify their path on disk. The usage is simplified and it allows us
to include them in our unit tests.
This also means that from now on PhpSpreadsheet must use composer autoloader
mechanism. The internal autoloading implementation was dropped.
The OOXML spec defines the font sizes (the `sz` element) as a double, so the value needs to be wrapped in `PHPExcel_Shared_String::FormatNumber()` to avoid breaking in non-English locales.
`RichText` tries to extract container cell's font via
`Cell->getParent()->getStyle(...)`, which crashes because
`getParent()` does not return a worksheet. Changing it to
`getWorksheet()` fixes the problem.
If $a or $b are not strings, you can get an error that fmod needs param 1 ($a) to be of type double.
MS Excel does not fall over when you insert an empty string in MOD, so I'm guessing PHPExcel should do the same?
For (still) unknown reasons, PHPExcel detects a wrong field type.
If there is no BSE Index, we will fail here and other fields are not read.
So if the BSE Index < 1, continue with the next field.
TODO: Why is there no BSE Index?
Is this a new Office Version?
Password protected field?
More likely : a uncompatible picture
PHP Notice: Undefined offset: -1 in Classes/PHPExcel/Reader/Excel5.php on line 1063
PHP Fatal error: Call to a member function getBlipType() on a non-object in Classes/PHPExcel/Reader/Excel5.php on line 1064
removeColumn doesn't remove all cells, because CacheBase::deleteCacheData only unsets cell data if they are objects.
But cached cell data could be arrays.
I moved the unset from inside the if block (line 150 ff) to after the if block.
BaseReader called `isValidFormat` despite it doesn't require it to be
implemented. Instead we replaced `isValidFormat` by a proper implementation
of `canRead` in each classes. This also remove the semantic amibguity between
those two methods.
FIX#32
This is to fix the situation when cells merged vertically are ignored in columns auto size calculations.
I also removed $calculateMergeCells param as it wasn't used and I believe the only situation when you
want to calculate the width of merged columns has been covered here (and there's no reason to not calculate it).
FIX#46
Some references to classes were incorrectly assumed to be a reference
to self, whereas they were references to classes in global namespace
outside of this project.
FIX#37
GD is implicitly required for saving images anyway, this exception when
it's not loaded simply gives more information on what to do if the
execution flow reaches a places that depends on a function from GD.
```php
<?php
$array = array(
'str' => 'foo',
'num' => 12345,
'null' => NULL,
);
print intval(isset($array['null'])) . PHP_EOL;
print intval(array_key_exists($array['null'])) . PHP_EOL;
print intval(isset($array['num'])) . PHP_EOL;
print intval(array_key_exists($array['num'])) . PHP_EOL;
print intval(isset($array['str'])) . PHP_EOL;
print intval(array_key_exists($array['str'])) . PHP_EOL;
```
Only for this special case, you need array_key_exists(), else avoid it as it is
painfully slow and hurts your performance.
Signed-off-by: Roland Häder <roland@mxchange.org>
Remove the term "hack" from the source code to prevent it
from being flagged by malware scanners and audit tools (such as
the very popular myJoomla.com for Joomla sites)
Remove the term "hacked by" from the source code to prevent it
from being flagged by malware scanners and audit tools (such as
the very popular myJoomla.com for Joomla sites)
If a sheet name included an apostrophe and the sheet had print area
defined then the spreadsheet could not be saved because the cell
coordinates were mangled, eg:
'Fiche d''action'!$A$1:$N$19
wrongly became:
'Fiche d'$A$1:$N$19
This introduce a helper class that should be used to log things,
avoiding a lot of boilerplate code.
Also all output are made in /tmp folder instead of beside the script
itself. This is because there is a high chance that the folder containing
the script is not writtable by webserver. So using the /tmp folder
makes it more likely to works in a variety of setup.
Yii framework v1.1 has it's own autoloader and its autoloader throws
an error, when it can't find class. When this library initializes, it
register its own autoloader, but places it at the end of autoload
queue. So when I use library with Yii 1.1, I just face an error:
`include(PHPExcel_Shared_String.php): failed to open stream: No such file or directory`
because Yii's autoloader runs first and tries to include class file
directly.
Registering our autoloader first avoid this.
Changes to Date/Time methods to make them more intuitive and correct (eg `excelToTimestamp` rather than `excelToPHP`)
TODO - Still need to write unit tests, and convert Examples to use the new names
This include cases were artificial constraints were not checked
(eg: between -512 and 511 for `DECBIN`) and some bugs were 32
bits platform were assumed.
The following are covered:
`BIN2DEC`, `BIN2HEX`, `BIN2OCT`,
`DEC2BIN`, `DEC2HEX`, `DEC2OCT`,
`HEX2BIN`, `HEX2DEC`, `HEX2OCT`,
`OCT2BIN`, `OCT2DEC`, `OCT2HEX`
Expected data were re-written by using LibreOffice 5 as a reference.
We kept only 8 decimals, because this is the precision used in tests,
and it's easier to read without scientific notation.
Also a few expected values were wrong so they were changed. The correct
expected values were confirmed by both LibreOffice 5 and wolframalpha.com.
Finally fixed an actual bug in code were a NaN value were returned instead of
the correct `#NUM!`.
But there's a lot of naughty homebrew xlsx writers that do use "reserved" id values that aren't actually used
So we make allowance for them rather than lose formatting masks