CodeIgniter Laravel PHP Example Javascript jQuery MORE Videos New
Need a Website Or Web Application Contact : +91 9437911966 (Whatsapp) Note: Paid Service

How to create multiple worksheet in phpspreadsheet Codeigniter


<?php
error_reporting(0);
defined('BASEPATH') OR exit('No direct script access allowed');
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
class EDSRS extends CI_Controller {

public function __construct()
    {
parent::__construct();
$this->load->library('form_validation');
$this->load->model('ScheduleDSRmodel');
}
    public function test(){
        $spreadsheet = new Spreadsheet();
        /* $sheet = $spreadsheet->getActiveSheet(); */
        $spreadsheet->setActiveSheetIndex(0)->setCellValue('A1', 'Hello');
        /* Rename worksheet */
        $spreadsheet->getActiveSheet()->setTitle('URL Added');
        $spreadsheet->createSheet();
        /* Add some data */
        $spreadsheet->setActiveSheetIndex(1)->setCellValue('A1', 'world!');
        /* Rename worksheet */
        $spreadsheet->getActiveSheet()->setTitle('URL Removed');
        $writer = new Xlsx($spreadsheet);
        $filename=date("d-m-Y").time();
        $writer->save("./uploads/dsr/excel/bl/$filename.xlsx");
    }
}