PHP code example of lekoala / silverstripe-excel-import-export

1. Go to this page and download the library: Download lekoala/silverstripe-excel-import-export library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lekoala / silverstripe-excel-import-export example snippets


   public function import($data, $form, $request)
    {
        if (!ExcelImportExport::checkImportForm($this)) {
            return false;
        }
        $handler = $data['ImportHandler'] ?? null;
        if ($handler == "default") {
            return parent::import($data, $form, $request);
        }
        return ExcelImportExport::useCustomHandler($handler, $form, $this);
    }

    public static function getImportDescription()
    {
        return "This is my custom description";
    }

    public static function getSampleFileLink()
    {
        return ExcelImportExport::createDownloadSampleLink(__CLASS__);
    }

    public static function getSampleFile()
    {
        $data = []; // TODO
        ExcelImportExport::createSampleFile($data, __CLASS__);
    }