Merge branch 'master' into PHP8-Testing

This commit is contained in:
MarkBaker 2020-10-08 03:09:21 +02:00
commit fdee43cfa1
8 changed files with 289 additions and 255 deletions

View File

@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Improve Coverage for ODS Reader [#1545](https://github.com/phpoffice/phpspreadsheet/pull/1545)
- Named formula implementation, and improved handling of Defined Names generally [#1535](https://github.com/PHPOffice/PhpSpreadsheet/pull/1535)
- fix resolution of relative named range values in the calculation engine; previously all named range values had been treated as absolute.
- Drop $this->spreadSheet null check from Xlsx Writer [#1646](https://github.com/phpoffice/phpspreadsheet/pull/1646)
### Deprecated
@ -49,6 +50,10 @@ and this project adheres to [Semantic Versioning](https://semver.org).
### Fixed
- PrintArea causes exception [#1544](https://github.com/phpoffice/phpspreadsheet/pull/1544)
- Calculation/DateTime Failure With PHP8 [#1661](https://github.com/phpoffice/phpspreadsheet/pull/1661)
- Reader/Gnumeric Failure with PHP8 [#1662](https://github.com/phpoffice/phpspreadsheet/pull/1662)
- ReverseSort bug, exposed but not caused by PHP8 [#1660](https://github.com/phpoffice/phpspreadsheet/pull/1660)
- Bug setting Superscript/Subscript to false [#1567](https://github.com/phpoffice/phpspreadsheet/pull/1567)
## 1.14.1 - 2020-07-19

View File

@ -8,7 +8,8 @@
[![License](https://poser.pugx.org/phpoffice/phpspreadsheet/license.png)](https://packagist.org/packages/phpoffice/phpspreadsheet)
[![Join the chat at https://gitter.im/PHPOffice/PhpSpreadsheet](https://img.shields.io/badge/GITTER-join%20chat-green.svg)](https://gitter.im/PHPOffice/PhpSpreadsheet)
PhpSpreadsheet is a library written in pure PHP and providing a set of classes that allow you to read from and to write to different spreadsheet file formats, like Excel and LibreOffice Calc.
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.
## Documentation

View File

@ -2,9 +2,8 @@
![Logo](./assets/logo.svg)
PhpSpreadsheet is a library written in pure PHP and providing a set of
classes that allow you to read from and to write to different
spreadsheet file formats, like Excel and LibreOffice Calc.
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.
## File formats supported

View File

@ -543,7 +543,8 @@ class Gnumeric extends BaseReader
$endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : (int) $styleAttributes['endCol'];
$endColumn = Coordinate::stringFromColumnIndex($endColumn + 1);
$endRow = 1 + (($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow']);
$endRow = 1 + (($styleAttributes['endRow'] > $maxRow) ? $maxRow : (int) $styleAttributes['endRow']);
$cellRange = $startColumn . $startRow . ':' . $endColumn . $endRow;
$styleAttributes = $styleRegion->Style->attributes();

View File

@ -69,7 +69,7 @@ class ReferenceHelper
*/
public static function columnReverseSort($a, $b)
{
return 1 - strcasecmp(strlen($a) . $a, strlen($b) . $b);
return -strcasecmp(strlen($a) . $a, strlen($b) . $b);
}
/**
@ -108,7 +108,7 @@ class ReferenceHelper
[$bc, $br] = sscanf($b, '%[A-Z]%d');
if ($ar === $br) {
return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
return -strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
}
return ($ar < $br) ? 1 : -1;

View File

@ -357,21 +357,18 @@ class Font extends Supervisor
/**
* Set Superscript.
*
* @param bool $pValue
*
* @return $this
*/
public function setSuperscript($pValue)
public function setSuperscript(bool $pValue)
{
if ($pValue == '') {
$pValue = false;
}
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['superscript' => $pValue]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->superscript = $pValue;
$this->subscript = !$pValue;
if ($this->superscript) {
$this->subscript = false;
}
}
return $this;
@ -394,21 +391,18 @@ class Font extends Supervisor
/**
* Set Subscript.
*
* @param bool $pValue
*
* @return $this
*/
public function setSubscript($pValue)
public function setSubscript(bool $pValue)
{
if ($pValue == '') {
$pValue = false;
}
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['subscript' => $pValue]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->subscript = $pValue;
$this->superscript = !$pValue;
if ($this->subscript) {
$this->superscript = false;
}
}
return $this;

View File

@ -178,7 +178,6 @@ class Xlsx extends BaseWriter
*/
public function save($pFilename): void
{
if ($this->spreadSheet !== null) {
// garbage collect
$this->pathNames = [];
$this->spreadSheet->garbageCollect();
@ -407,9 +406,6 @@ class Xlsx extends BaseWriter
}
$this->maybeCloseFileHandle();
} else {
throw new WriterException('PhpSpreadsheet object unassigned.');
}
}
/**
@ -419,13 +415,9 @@ class Xlsx extends BaseWriter
*/
public function getSpreadsheet()
{
if ($this->spreadSheet !== null) {
return $this->spreadSheet;
}
throw new WriterException('No Spreadsheet object assigned.');
}
/**
* Set Spreadsheet object.
*

View File

@ -0,0 +1,42 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Style;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PHPUnit\Framework\TestCase;
class FontTest extends TestCase
{
public function testSuperSubScript(): void
{
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$cell = $sheet->getCell('A1');
$cell->setValue('Cell A1');
$font = $cell->getStyle()->getFont();
$font->setSuperscript(true);
$font->setSubscript(true);
self::assertFalse($font->getSuperscript(), 'Earlier set true loses');
self::assertTrue($font->getSubscript(), 'Last set true wins');
$font->setSubscript(true);
$font->setSuperscript(true);
self::assertTrue($font->getSuperscript(), 'Last set true wins');
self::assertFalse($font->getSubscript(), 'Earlier set true loses');
$font->setSuperscript(false);
$font->setSubscript(false);
self::assertFalse($font->getSuperscript(), 'False remains unchanged');
self::assertFalse($font->getSubscript(), 'False remains unchanged');
$font->setSubscript(false);
$font->setSuperscript(false);
self::assertFalse($font->getSuperscript(), 'False remains unchanged');
self::assertFalse($font->getSubscript(), 'False remains unchanged');
$font->setSubscript(true);
$font->setSuperscript(false);
self::assertFalse($font->getSuperscript(), 'False remains unchanged');
self::assertTrue($font->getSubscript(), 'True remains unchanged');
$font->setSubscript(false);
$font->setSuperscript(true);
self::assertTrue($font->getSuperscript());
self::assertFalse($font->getSubscript(), 'False remains unchanged');
}
}