/** * Write the row to the file */ public function add_row($row) { if ($this->row >= self::MAXROWS) { $this->worksheet++; $this->writer =& $this->workbook->add_worksheet("{$this->name} {$this->worksheet}"); $this->row = 0; } $column = 0; foreach ($row as $cell) { if (is_numeric($cell)) { $this->writer->write_number($this->row, $column, $cell); } else { $this->writer->write_string($this->row, $column, $cell); } $column++; } $this->row++; }
/** * Set file column widths for Excel files. * * @param string[] $columns Column names. * @param MoodleExcelWorksheet $worksheet The worksheet. */ protected function set_column_widths($columns, $worksheet) { $lastcolumnindex = count($columns) - 1; $worksheet->set_column(0, $lastcolumnindex, tool_downloaddata_config::$columnwidths['default']); foreach ($columns as $no => $name) { if (isset(tool_downloaddata_config::$columnwidths[$name])) { $worksheet->set_column($no, $no, tool_downloaddata_config::$columnwidths[$name]); } } }