MDL-68500 dataformat: allow instances to export to local file.
This commit is contained in:
@@ -66,6 +66,23 @@ abstract class spout_base extends \core\dataformat\base {
|
||||
$this->renamecurrentsheet = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
if (method_exists($this->writer, 'setTempFolder')) {
|
||||
$this->writer->setTempFolder(make_request_directory());
|
||||
}
|
||||
|
||||
$this->writer->openToFile($this->filepath);
|
||||
|
||||
// By default one sheet is always created, but we want to rename it when we call start_sheet().
|
||||
$this->renamecurrentsheet = true;
|
||||
|
||||
$this->start_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title of the worksheet inside a spreadsheet
|
||||
*
|
||||
@@ -114,4 +131,15 @@ abstract class spout_base extends \core\dataformat\base {
|
||||
$this->writer->close();
|
||||
$this->writer = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to disk
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function close_output_to_file(): bool {
|
||||
$this->close_output();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user