diff --git a/dataformat/csv/classes/writer.php b/dataformat/csv/classes/writer.php index 36b9eac858a..79562169620 100644 --- a/dataformat/csv/classes/writer.php +++ b/dataformat/csv/classes/writer.php @@ -42,7 +42,7 @@ class writer extends \core\dataformat\spout_base { protected $extension = ".csv"; /** @var $spouttype */ - protected $spouttype = \Box\Spout\Common\Type::CSV; + protected $spouttype = \OpenSpout\Common\Type::CSV; } diff --git a/dataformat/excel/classes/writer.php b/dataformat/excel/classes/writer.php index 269e9b87a34..5e73a4e94ce 100644 --- a/dataformat/excel/classes/writer.php +++ b/dataformat/excel/classes/writer.php @@ -42,7 +42,7 @@ class writer extends \core\dataformat\spout_base { protected $extension = ".xlsx"; /** @var $spouttype */ - protected $spouttype = \Box\Spout\Common\Type::XLSX; + protected $spouttype = \OpenSpout\Common\Type::XLSX; /** * Set the title of the worksheet inside a spreadsheet diff --git a/dataformat/excel/tests/writer_test.php b/dataformat/excel/tests/writer_test.php index ec9fce708ba..1a8e139442d 100644 --- a/dataformat/excel/tests/writer_test.php +++ b/dataformat/excel/tests/writer_test.php @@ -57,15 +57,15 @@ class writer_test extends \advanced_testcase { $file = tempnam(sys_get_temp_dir(), 'excel_'); $handle = fopen($file, "w"); fwrite($handle, $content); - /** @var \Box\Spout\Reader\XLSX\Reader $reader */ - $reader = \Box\Spout\Reader\Common\Creator\ReaderFactory::createFromType(\Box\Spout\Common\Type::XLSX); + /** @var \OpenSpout\Reader\XLSX\Reader $reader */ + $reader = \OpenSpout\Reader\Common\Creator\ReaderFactory::createFromType(\OpenSpout\Common\Type::XLSX); $reader->open($file); - /** @var \Box\Spout\Reader\XLSX\Sheet[] $sheets */ + /** @var \OpenSpout\Reader\XLSX\Sheet[] $sheets */ $sheets = $reader->getSheetIterator(); $rowscellsvalues = []; foreach ($sheets as $sheet) { - /** @var \Box\Spout\Common\Entity\Row[] $rows */ + /** @var \OpenSpout\Common\Entity\Row[] $rows */ $rows = $sheet->getRowIterator(); foreach ($rows as $row) { $thisvalues = []; diff --git a/dataformat/ods/classes/writer.php b/dataformat/ods/classes/writer.php index 9418abe652e..7c94d39a79a 100644 --- a/dataformat/ods/classes/writer.php +++ b/dataformat/ods/classes/writer.php @@ -42,7 +42,7 @@ class writer extends \core\dataformat\spout_base { protected $extension = ".ods"; /** @var $spouttype */ - protected $spouttype = \Box\Spout\Common\Type::ODS; + protected $spouttype = \OpenSpout\Common\Type::ODS; /** * Set the title of the worksheet inside a spreadsheet diff --git a/dataformat/ods/tests/writer_test.php b/dataformat/ods/tests/writer_test.php index fe71ab0f50b..c905f1519a5 100644 --- a/dataformat/ods/tests/writer_test.php +++ b/dataformat/ods/tests/writer_test.php @@ -51,20 +51,20 @@ class writer_test extends \advanced_testcase { * Get ods rows from binary content * @param string $content * @return array - * @throws \Box\Spout\Common\Exception\IOException - * @throws \Box\Spout\Reader\Exception\ReaderNotOpenedException + * @throws \OpenSpout\Common\Exception\IOException + * @throws \OpenSpout\Reader\Exception\ReaderNotOpenedException */ private function get_ods_rows_content($content) { - $reader = \Box\Spout\Reader\Common\Creator\ReaderFactory::createFromType(\Box\Spout\Common\Type::ODS); + $reader = \OpenSpout\Reader\Common\Creator\ReaderFactory::createFromType(\OpenSpout\Common\Type::ODS); $file = tempnam(sys_get_temp_dir(), 'ods_'); $handle = fopen($file, "w"); fwrite($handle, $content); $reader->open($file); - /** @var \Box\Spout\Reader\ODS\Sheet[] $sheets */ + /** @var \OpenSpout\Reader\ODS\Sheet[] $sheets */ $sheets = $reader->getSheetIterator(); $rowscellsvalues = []; foreach ($sheets as $sheet) { - /** @var \Box\Spout\Common\Entity\Row[] $rows */ + /** @var \OpenSpout\Common\Entity\Row[] $rows */ $rows = $sheet->getRowIterator(); foreach ($rows as $row) { $thisvalues = []; diff --git a/lib/classes/dataformat/spout_base.php b/lib/classes/dataformat/spout_base.php index 4c582707ec3..3f1ba427ef0 100644 --- a/lib/classes/dataformat/spout_base.php +++ b/lib/classes/dataformat/spout_base.php @@ -51,7 +51,7 @@ abstract class spout_base extends \core\dataformat\base { * Output file headers to initialise the download of the file. */ public function send_http_headers() { - $this->writer = \Box\Spout\Writer\Common\Creator\WriterEntityFactory::createWriter($this->spouttype); + $this->writer = \OpenSpout\Writer\Common\Creator\WriterEntityFactory::createWriter($this->spouttype); if (method_exists($this->writer, 'setTempFolder')) { $this->writer->setTempFolder(make_request_directory()); } @@ -70,7 +70,7 @@ abstract class spout_base extends \core\dataformat\base { * Set the dataformat to be output to current file */ public function start_output_to_file(): void { - $this->writer = \Box\Spout\Writer\Common\Creator\WriterEntityFactory::createWriter($this->spouttype); + $this->writer = \OpenSpout\Writer\Common\Creator\WriterEntityFactory::createWriter($this->spouttype); if (method_exists($this->writer, 'setTempFolder')) { $this->writer->setTempFolder(make_request_directory()); } @@ -100,7 +100,7 @@ abstract class spout_base extends \core\dataformat\base { * @param array $columns */ public function start_sheet($columns) { - if ($this->sheettitle && $this->writer instanceof \Box\Spout\Writer\WriterMultiSheetsAbstract) { + if ($this->sheettitle && $this->writer instanceof \OpenSpout\Writer\WriterMultiSheetsAbstract) { if ($this->renamecurrentsheet) { $sheet = $this->writer->getCurrentSheet(); $this->renamecurrentsheet = false; @@ -109,7 +109,7 @@ abstract class spout_base extends \core\dataformat\base { } $sheet->setName($this->sheettitle); } - $row = \Box\Spout\Writer\Common\Creator\WriterEntityFactory::createRowFromArray((array)$columns); + $row = \OpenSpout\Writer\Common\Creator\WriterEntityFactory::createRowFromArray((array)$columns); $this->writer->addRow($row); } @@ -120,7 +120,7 @@ abstract class spout_base extends \core\dataformat\base { * @param int $rownum */ public function write_record($record, $rownum) { - $row = \Box\Spout\Writer\Common\Creator\WriterEntityFactory::createRowFromArray($this->format_record($record)); + $row = \OpenSpout\Writer\Common\Creator\WriterEntityFactory::createRowFromArray($this->format_record($record)); $this->writer->addRow($row); } diff --git a/lib/db/renamedclasses.php b/lib/db/renamedclasses.php index 6547bfd22c5..01b3ada5bff 100644 --- a/lib/db/renamedclasses.php +++ b/lib/db/renamedclasses.php @@ -90,4 +90,6 @@ $renamedclasses = [ 'core_cohort\\local\\entities\\cohort' => 'core_cohort\\reportbuilder\\local\\entities\\cohort', 'core_cohort\\local\\entities\\cohort_member' => 'core_cohort\\reportbuilder\\local\\entities\\cohort_member', 'core_block\\local\\views\\secondary' => 'core_block\\navigation\\views\\secondary', + // Since Moodle 4.2. + 'Box\\Spout' => 'OpenSpout', ];