public static function save($filename='excel', $format='Xlsx')
    {
        $objPhpSpreadsheet = self::validExcelObj();

        // Create Writer first
        $objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, $format);

        /**
         * Type Mapping
         */
        $inTypeList = isset(self::$_writerTypeInfo[$format]) ? true : false;
        $extension = ($inTypeList) ? self::$_writerTypeInfo[$format]['extension'] : '';
        
        // Check if filename contained extension
        $filepath = (stripos($filename, $extension)===(strlen($filename)-strlen($extension)))
            ? $filename 
            : "{$filename}{$extension}";

        // Save file
        $objWriter->save($filepath);
        return $filepath;
    }
public static function save($filename='excel', $format='Xlsx')
    {
        $objPhpSpreadsheet = self::validExcelObj();

        // Create Writer first
        $objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, $format);

        /**
         * Type Mapping
         */
        $inTypeList = isset(self::$_writerTypeInfo[$format]) ? true : false;
        $extension = ($inTypeList) ? self::$_writerTypeInfo[$format]['extension'] : '';
        
        // Check if filename contained extension
        $filepath = (stripos($filename, $extension)===(strlen($filename)-strlen($extension)))
            ? $filename 
            : "{$filename}{$extension}";

        // Save file
        $objWriter->save($filepath);
        return $filepath;
    }
public static function save ( $ filename = 'excel' , $ format = 'Xlsx' ) { $ objPhpSpreadsheet = self :: validExcelObj ( ) ; // Create Writer first $ objWriter = \ PhpOffice \ PhpSpreadsheet \ IOFactory :: createWriter ( $ objPhpSpreadsheet , $ format ) ; /**
         * Type Mapping
         */ $ inTypeList = isset ( self :: $ _writerTypeInfo [ $ format ] ) ? true : false ; $ extension = ( $ inTypeList ) ? self :: $ _writerTypeInfo [ $ format ] [ 'extension' ] : '' ; // Check if filename contained extension $ filepath = ( stripos ( $ filename , $ extension ) === ( strlen ( $ filename ) - strlen ( $ extension ) ) ) ? $ filename : "{$filename}{$extension}" ; // Save file $ objWriter -> save ( $ filepath ) ; return $ filepath ; }
Save as file

@param string $filename Support file path
@param string $format
@return string Filepath
Save as file