| Línea 22... | Línea 22... | 
          
            | 22 |  * @package    core
 | 22 |  * @package    core
 | 
          
            | 23 |  */
 | 23 |  */
 | 
          
            | Línea 24... | Línea 24... | 
          
            | 24 |  
 | 24 |  
 | 
          
            | Línea 25... | Línea 25... | 
          
            | 25 | defined('MOODLE_INTERNAL') || die();
 | 25 | defined('MOODLE_INTERNAL') || die();
 | 
          
            | 26 |  
 | - |   | 
          
            | - |   | 26 |  
 | 
          
            | 27 | require_once("$CFG->libdir/phpspreadsheet/vendor/autoload.php");
 | 27 | use PhpOffice\PhpSpreadsheet\Cell\CellAddress;
 | 
          
            | 28 |  
 | 28 | use PhpOffice\PhpSpreadsheet\Cell\CellRange;
 | 
          
            | 29 | use \PhpOffice\PhpSpreadsheet\Spreadsheet;
 | 29 | use PhpOffice\PhpSpreadsheet\Spreadsheet;
 | 
          
            | 30 | use \PhpOffice\PhpSpreadsheet\IOFactory;
 | 30 | use PhpOffice\PhpSpreadsheet\IOFactory;
 | 
          
            | 31 | use \PhpOffice\PhpSpreadsheet\Cell\Coordinate;
 | 31 | use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
 | 
          
            | 32 | use \PhpOffice\PhpSpreadsheet\Cell\DataType;
 | 32 | use PhpOffice\PhpSpreadsheet\Cell\DataType;
 | 
          
            | 33 | use \PhpOffice\PhpSpreadsheet\Shared\Date;
 | 33 | use PhpOffice\PhpSpreadsheet\Shared\Date;
 | 
          
            | 34 | use \PhpOffice\PhpSpreadsheet\Style\Alignment;
 | 34 | use PhpOffice\PhpSpreadsheet\Style\Alignment;
 | 
          
            | 35 | use \PhpOffice\PhpSpreadsheet\Style\Border;
 | 35 | use PhpOffice\PhpSpreadsheet\Style\Border;
 | 
          
            | 36 | use \PhpOffice\PhpSpreadsheet\Style\Fill;
 | 36 | use PhpOffice\PhpSpreadsheet\Style\Fill;
 | 
          
            | 37 | use \PhpOffice\PhpSpreadsheet\Style\Font;
 | 37 | use PhpOffice\PhpSpreadsheet\Style\Font;
 | 
          
            | 38 | use \PhpOffice\PhpSpreadsheet\Style\NumberFormat;
 | 38 | use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
 | 
          
            | Línea 39... | Línea 39... | 
          
            | 39 | use \PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
 | 39 | use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
 | 
          
            | 40 | use \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
 | 40 | use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
 | 
          
            | 41 |  
 | 41 |  
 | 
          
            | 42 | /**
 | 42 | /**
 | 
          
            | Línea 201... | Línea 201... | 
          
            | 201 |      */
 | 201 |      */
 | 
          
            | 202 |     public function write_string($row, $col, $str, $format = null) {
 | 202 |     public function write_string($row, $col, $str, $format = null) {
 | 
          
            | 203 |         // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
 | 203 |         // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
 | 
          
            | 204 |         $col += 1;
 | 204 |         $col += 1;
 | 
          
            | Línea -... | Línea 205... | 
          
            | - |   | 205 |  
 | 
          
            | - |   | 206 |         $celladdress = CellAddress::fromColumnAndRow($col, $row + 1);
 | 
          
            | 205 |  
 | 207 |  
 | 
          
            | 206 |         $this->worksheet->getStyleByColumnAndRow($col, $row + 1)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
 | 208 |         $this->worksheet->getStyle($celladdress)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
 | 
          
            | 207 |         $this->worksheet->setCellValueExplicitByColumnAndRow($col, $row + 1, $str, DataType::TYPE_STRING);
 | 209 |         $this->worksheet->getCell($celladdress)->setValueExplicit($str, DataType::TYPE_STRING);
 | 
          
            | 208 |         $this->apply_format($row, $col, $format);
 | 210 |         $this->apply_format($row, $col, $format);
 | 
          
            | Línea 209... | Línea 211... | 
          
            | 209 |     }
 | 211 |     }
 | 
          
            | 210 |  
 | 212 |  
 | 
          
            | Línea 218... | Línea 220... | 
          
            | 218 |      */
 | 220 |      */
 | 
          
            | 219 |     public function write_number($row, $col, $num, $format = null) {
 | 221 |     public function write_number($row, $col, $num, $format = null) {
 | 
          
            | 220 |         // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
 | 222 |         // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
 | 
          
            | 221 |         $col += 1;
 | 223 |         $col += 1;
 | 
          
            | Línea -... | Línea 224... | 
          
            | - |   | 224 |  
 | 
          
            | - |   | 225 |         $celladdress = CellAddress::fromColumnAndRow($col, $row + 1);
 | 
          
            | 222 |  
 | 226 |  
 | 
          
            | 223 |         $this->worksheet->getStyleByColumnAndRow($col, $row + 1)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_GENERAL);
 | 227 |         $this->worksheet->getStyle($celladdress)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_GENERAL);
 | 
          
            | 224 |         $this->worksheet->setCellValueExplicitByColumnAndRow($col, $row + 1, $num, DataType::TYPE_NUMERIC);
 | 228 |         $this->worksheet->getCell($celladdress)->setValueExplicit($num, DataType::TYPE_NUMERIC);
 | 
          
            | 225 |         $this->apply_format($row, $col, $format);
 | 229 |         $this->apply_format($row, $col, $format);
 | 
          
            | Línea 226... | Línea 230... | 
          
            | 226 |     }
 | 230 |     }
 | 
          
            | 227 |  
 | 231 |  
 | 
          
            | Línea 235... | Línea 239... | 
          
            | 235 |      */
 | 239 |      */
 | 
          
            | 236 |     public function write_url($row, $col, $url, $format = null) {
 | 240 |     public function write_url($row, $col, $url, $format = null) {
 | 
          
            | 237 |         // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
 | 241 |         // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
 | 
          
            | 238 |         $col += 1;
 | 242 |         $col += 1;
 | 
          
            | Línea 239... | Línea 243... | 
          
            | 239 |  
 | 243 |  
 | 
          
            | - |   | 244 |         $celladdress = CellAddress::fromColumnAndRow($col, $row + 1);
 | 
          
            | - |   | 245 |  
 | 
          
            | - |   | 246 |         $cell = $this->worksheet->getCell($celladdress);
 | 
          
            | 240 |         $this->worksheet->setCellValueByColumnAndRow($col, $row + 1, $url);
 | 247 |         $cell->setValue($url);
 | 
          
            | 241 |         $this->worksheet->getCellByColumnAndRow($col, $row + 1)->getHyperlink()->setUrl($url);
 | 248 |         $cell->getHyperlink()->setUrl($url);
 | 
          
            | 242 |         $this->apply_format($row, $col, $format);
 | 249 |         $this->apply_format($row, $col, $format);
 | 
          
            | Línea 243... | Línea 250... | 
          
            | 243 |     }
 | 250 |     }
 | 
          
            | 244 |  
 | 251 |  
 | 
          
            | Línea 261... | Línea 268... | 
          
            | 261 |             $getdate['hours'],
 | 268 |             $getdate['hours'],
 | 
          
            | 262 |             $getdate['minutes'],
 | 269 |             $getdate['minutes'],
 | 
          
            | 263 |             $getdate['seconds']
 | 270 |             $getdate['seconds']
 | 
          
            | 264 |         );
 | 271 |         );
 | 
          
            | Línea 265... | Línea 272... | 
          
            | 265 |  
 | 272 |  
 | 
          
            | - |   | 273 |         $celladdress = CellAddress::fromColumnAndRow($col, $row + 1);
 | 
          
            | 266 |         $this->worksheet->setCellValueByColumnAndRow($col, $row + 1, $exceldate);
 | 274 |  
 | 
          
            | 267 |         $style = $this->worksheet->getStyleByColumnAndRow($col, $row + 1);
 | 275 |         $this->worksheet->getCell($celladdress)->setValue($exceldate);
 | 
          
            | 268 |         $style->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_XLSX22);
 | 276 |         $this->worksheet->getStyle($celladdress)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_XLSX22);
 | 
          
            | 269 |         $this->apply_format($row, $col, $format);
 | 277 |         $this->apply_format($row, $col, $format);
 | 
          
            | Línea 270... | Línea 278... | 
          
            | 270 |     }
 | 278 |     }
 | 
          
            | 271 |  
 | 279 |  
 | 
          
            | Línea 279... | Línea 287... | 
          
            | 279 |      */
 | 287 |      */
 | 
          
            | 280 |     public function write_formula($row, $col, $formula, $format = null) {
 | 288 |     public function write_formula($row, $col, $formula, $format = null) {
 | 
          
            | 281 |         // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
 | 289 |         // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
 | 
          
            | 282 |         $col += 1;
 | 290 |         $col += 1;
 | 
          
            | Línea -... | Línea 291... | 
          
            | - |   | 291 |  
 | 
          
            | 283 |  
 | 292 |         $celladdress = CellAddress::fromColumnAndRow($col, $row + 1);
 | 
          
            | 284 |         $this->worksheet->setCellValueExplicitByColumnAndRow($col, $row + 1, $formula, DataType::TYPE_FORMULA);
 | 293 |         $this->worksheet->getCell($celladdress)->setValueExplicit($formula, DataType::TYPE_FORMULA);
 | 
          
            | 285 |         $this->apply_format($row, $col, $format);
 | 294 |         $this->apply_format($row, $col, $format);
 | 
          
            | Línea 286... | Línea 295... | 
          
            | 286 |     }
 | 295 |     }
 | 
          
            | 287 |  
 | 296 |  
 | 
          
            | Línea 294... | Línea 303... | 
          
            | 294 |      */
 | 303 |      */
 | 
          
            | 295 |     public function write_blank($row, $col, $format = null) {
 | 304 |     public function write_blank($row, $col, $format = null) {
 | 
          
            | 296 |         // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
 | 305 |         // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
 | 
          
            | 297 |         $col += 1;
 | 306 |         $col += 1;
 | 
          
            | Línea 298... | Línea 307... | 
          
            | 298 |  
 | 307 |  
 | 
          
            | - |   | 308 |         $celladdress = CellAddress::fromColumnAndRow($col, $row + 1);
 | 
          
            | 299 |         $this->worksheet->setCellValueByColumnAndRow($col, $row + 1, '');
 | 309 |         $this->worksheet->getCell($celladdress)->setValue('');
 | 
          
            | 300 |         $this->apply_format($row, $col, $format);
 | 310 |         $this->apply_format($row, $col, $format);
 | 
          
            | Línea 301... | Línea 311... | 
          
            | 301 |     }
 | 311 |     }
 | 
          
            | 302 |  
 | 312 |  
 | 
          
            | Línea 443... | Línea 453... | 
          
            | 443 |     * @param integer $lastrow  Last row of the area to merge
 | 453 |     * @param integer $lastrow  Last row of the area to merge
 | 
          
            | 444 |     * @param integer $lastcol  Last column of the area to merge
 | 454 |     * @param integer $lastcol  Last column of the area to merge
 | 
          
            | 445 |     */
 | 455 |     */
 | 
          
            | 446 |     public function merge_cells($firstrow, $firstcol, $lastrow, $lastcol) {
 | 456 |     public function merge_cells($firstrow, $firstcol, $lastrow, $lastcol) {
 | 
          
            | 447 |         // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
 | 457 |         // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
 | 
          
            | - |   | 458 |         $this->worksheet->mergeCells(
 | 
          
            | - |   | 459 |             new CellRange(
 | 
          
            | 448 |         $this->worksheet->mergeCellsByColumnAndRow($firstcol + 1, $firstrow + 1, $lastcol + 1, $lastrow + 1);
 | 460 |                 CellAddress::fromColumnAndRow($firstcol + 1, $firstrow + 1),
 | 
          
            | - |   | 461 |                 CellAddress::fromColumnAndRow($lastcol + 1, $lastrow + 1),
 | 
          
            | - |   | 462 |             )
 | 
          
            | - |   | 463 |         );
 | 
          
            | 449 |     }
 | 464 |     }
 | 
          
            | Línea 450... | Línea 465... | 
          
            | 450 |  
 | 465 |  
 | 
          
            | 451 |     protected function apply_format($row, $col, $format = null) {
 | 466 |     protected function apply_format($row, $col, $format = null) {
 | 
          
            | 452 |         if (!$format) {
 | 467 |         if (!$format) {
 | 
          
            | 453 |             $format = new MoodleExcelFormat();
 | 468 |             $format = new MoodleExcelFormat();
 | 
          
            | 454 |         } else if (is_array($format)) {
 | 469 |         } else if (is_array($format)) {
 | 
          
            | 455 |             $format = new MoodleExcelFormat($format);
 | 470 |             $format = new MoodleExcelFormat($format);
 | 
          
            | 456 |         }
 | 471 |         }
 | 
          
            | 457 |         $this->worksheet->getStyleByColumnAndRow($col, $row + 1)->applyFromArray($format->get_format_array());
 | 472 |         $this->worksheet->getStyle(CellAddress::fromColumnAndRow($col, $row + 1))->applyFromArray($format->get_format_array());
 | 
          
            | Línea 458... | Línea 473... | 
          
            | 458 |     }
 | 473 |     }
 | 
          
            | 459 |  
 | 474 |  
 | 
          
            | 460 |     protected function apply_column_format($col, $format = null) {
 | 475 |     protected function apply_column_format($col, $format = null) {
 |