public static function num2alpha($n)
    {
        $n = $n - 1;
        $r = '';
        for ($i = 1; $n >= 0 && $i < 10; $i++) {
            $r = chr(0x41 + ($n % pow(26, $i) / pow(26, $i - 1))) . $r;
            $n -= pow(26, $i);
        }
        return $r;
    }
public static function num2alpha($n)
    {
        $n = $n - 1;
        $r = '';
        for ($i = 1; $n >= 0 && $i < 10; $i++) {
            $r = chr(0x41 + ($n % pow(26, $i) / pow(26, $i - 1))) . $r;
            $n -= pow(26, $i);
        }
        return $r;
    }
public static function num2alpha ( $ n ) { $ n = $ n - 1 ; $ r = '' ; for ( $ i = 1 ; $ n >= 0 && $ i < 10 ; $ i ++ ) { $ r = chr ( 0x41 + ( $ n % pow ( 26 , $ i ) / pow ( 26 , $ i - 1 ) ) ) . $ r ; $ n -= pow ( 26 , $ i ) ; } return $ r ; }
Number to Alpha

Optimizing from \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex()

@example
1 => A, 27 => AA
@param int $n column number
@return string Excel column alpha
Number to Alpha