Commit bf4042a2 authored by firfin's avatar firfin Committed by claudiu.cristea

Issue #2932815 by firfin, claudiu.cristea: Breaking updates in phpoffice/phpspreadsheet

parent fc2cc00b
......@@ -13,7 +13,7 @@
"Excel"
],
"require": {
"phpoffice/phpspreadsheet": "1.0.0-beta"
"phpoffice/phpspreadsheet": "^1.0.0"
},
"minimum-stability": "dev",
"prefer-stable": true
......
......@@ -148,7 +148,7 @@ class Spreadsheet extends SourcePluginBase implements ConfigurablePluginInterfac
/**
* Loads the worksheet.
*
* @return \PhpOffice\PhpSpreadsheet\Worksheet
* @return \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
* The source worksheet.
*
* @throws \Drupal\migrate\MigrateException
......
......@@ -2,8 +2,8 @@
namespace Drupal\migrate_spreadsheet;
use PhpOffice\PhpSpreadsheet\Cell;
use PhpOffice\PhpSpreadsheet\Worksheet;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
/**
* Provides a spreadsheet iterator.
......@@ -161,11 +161,11 @@ class SpreadsheetIterator implements SpreadsheetIteratorInterface {
// starts on the second row, column A.
return 'A2';
}
if ($coordinates = Cell::coordinateFromString($config['origin'])) {
if ($coordinates = Coordinate::coordinateFromString($config['origin'])) {
$row_count = $this->getRowsCount();
$column_count = $this->getColumnsCount();
if (($coordinates[1] > $row_count) || ((Cell::columnIndexFromString($coordinates[0])) > $column_count)) {
$max = Cell::stringFromColumnIndex($column_count - 1) . $row_count;
if (($coordinates[1] > $row_count) || ((Coordinate::columnIndexFromString($coordinates[0])) > $column_count)) {
$max = Coordinate::stringFromColumnIndex($column_count) . $row_count;
throw new \InvalidArgumentException("Origin '{$config['origin']}' is out of bounds. Max value is '$max'.");
}
}
......@@ -250,10 +250,10 @@ class SpreadsheetIterator implements SpreadsheetIteratorInterface {
*/
public function getHeaders() {
if (!isset($this->cache['headers'])) {
// Get the first column index (zero based).
$first_col_index = Cell::columnIndexFromString(Cell::coordinateFromString($this->getOrigin())[0]) - 1;
for ($col_index = $first_col_index; $col_index < $this->getColumnsCount(); ++$col_index) {
$col_letter = Cell::stringFromColumnIndex($col_index);
// Get the first column index (one based, A is 1).
$first_col_index = Coordinate::columnIndexFromString(Coordinate::coordinateFromString($this->getOrigin())[0]);
for ($col_index = $first_col_index; $col_index <= $this->getColumnsCount(); ++$col_index) {
$col_letter = Coordinate::stringFromColumnIndex($col_index);
if ($header_row = $this->getHeaderRow()) {
if ($cell = $this->getWorksheet()->getCell("$col_letter$header_row", FALSE)) {
$value = trim($cell->getValue());
......@@ -289,7 +289,7 @@ class SpreadsheetIterator implements SpreadsheetIteratorInterface {
*/
public function getColumnsCount() {
if (!isset($this->cache['columns_count'])) {
$this->cache['columns_count'] = Cell::columnIndexFromString($this->getWorksheet()->getHighestDataColumn());
$this->cache['columns_count'] = Coordinate::columnIndexFromString($this->getWorksheet()->getHighestDataColumn());
}
return $this->cache['columns_count'];
}
......@@ -308,7 +308,7 @@ class SpreadsheetIterator implements SpreadsheetIteratorInterface {
*/
protected function getAbsoluteRowIndex() {
if (!isset($this->absoluteRow)) {
$row = Cell::coordinateFromString($this->getOrigin())[1];
$row = Coordinate::coordinateFromString($this->getOrigin())[1];
$this->absoluteRow = $row + $this->relativeRow;
}
return $this->absoluteRow;
......
......@@ -14,7 +14,7 @@ interface SpreadsheetIteratorInterface extends \Iterator{
*
* @param array $configuration
* An associative array with the next keys:
* - worksheet (\PhpOffice\PhpSpreadsheet\Worksheet): The worksheet object.
* - worksheet (\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet): The worksheet object.
* - columns (string[]): An indexed array of columns.
* - keys (string[]): A list of columns that are giving the primary key.
* - header_row (int): The index of the first row from where the table
......@@ -43,7 +43,7 @@ interface SpreadsheetIteratorInterface extends \Iterator{
/**
* Gets the worksheet.
*
* @return \PhpOffice\PhpSpreadsheet\Worksheet
* @return \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
*
* @throws \InvalidArgumentException
* If an empty or invalid 'worksheet' has been passed.
......
......@@ -4,7 +4,7 @@ namespace Drupal\Tests\migrate_spreadsheet\Unit;
use Drupal\migrate_spreadsheet\SpreadsheetIterator;
use Drupal\Tests\UnitTestCase;
use PhpOffice\PhpSpreadsheet\Worksheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
/**
* Tests the spreadsheet iterator.
......@@ -18,7 +18,7 @@ class SpreadsheetIteratorTest extends UnitTestCase {
/**
* A worksheet.
*
* @var \PhpOffice\PhpSpreadsheet\Worksheet
* @var \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
*/
protected $worksheet;
......@@ -177,7 +177,7 @@ class SpreadsheetIteratorTest extends UnitTestCase {
/**
* Populates a testing worksheet.
*
* @return \PhpOffice\PhpSpreadsheet\Worksheet
* @return \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
*/
protected function getWorksheet() {
if (!isset($this->worksheet)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment