MDL-56046 core_dataformat: added functions to support multiple sheets

Also removed write_header() and write_footer(). The reason for this
is because in core we want to know if the format being used supports
multiple sheets. To do this, and ensure we do not break third-party
dataformat plugins, we are using method_exist(). If write_header()
and write_footer() remain in the base class then this will always
be true.
This commit is contained in:
Mark Nelson
2017-06-26 13:28:44 +08:00
parent cccb1a6d21
commit d7a2d1a2c8
2 changed files with 21 additions and 13 deletions
+4 -7
View File
@@ -75,11 +75,11 @@ abstract class spout_base extends \core\dataformat\base {
}
/**
* Write the start of the format
* Write the start of the sheet we will be adding data to.
*
* @param array $columns
*/
public function write_header($columns) {
public function start_sheet($columns) {
$this->writer->addRow(array_values((array)$columns));
}
@@ -94,13 +94,10 @@ abstract class spout_base extends \core\dataformat\base {
}
/**
* Write the end of the format
*
* @param array $columns
* Write the end of the file.
*/
public function write_footer($columns) {
public function close_output() {
$this->writer->close();
$this->writer = null;
}
}