<?php

namespace Modules\Shared\Helpers\Excel;

class SheetColumHandler
{
    public static function rangeCharsForAscii($start, $end)
    {
        $chars = [];

        for ($i = $start; $i <= $end; $i++) {
            $chars[] = chr($i);
        }

        return $chars;
    }

    public static function getAllChars()
    {
        $all_letters_excel = [];

        $all_letters = static::rangeCharsForAscii(65, 90);

        foreach (["", "A", "B"] as $prefix) {
            foreach ($all_letters as $subletter) {
                $all_letters_excel[] = "{$prefix}{$subletter}";
            }
        }

        return $all_letters_excel;
    }

    public static function getColumnsExcel($number_start, $number_columns)
    {
        $all_letters = static::getAllChars();

        return array_slice($all_letters, $number_start, $number_columns);
    }
}
