Created
September 23, 2022 05:43
-
-
Save manchumahara/f2d72e8eb5beb8808cfe636bf8b983d5 to your computer and use it in GitHub Desktop.
phpexcel next column prev column letter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Next letter for excel | |
* | |
* @param string $current_letter | |
* | |
* @return string | |
* @throws \PhpOffice\PhpSpreadsheet\Exception | |
*/ | |
function excel_next_letter($current_letter = 'A') | |
{ | |
$columnAlpha_index = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($current_letter); | |
$letter = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($columnAlpha_index + 1); | |
return $letter; | |
}//end excel_next_letter | |
/** | |
* Previous letter for excel | |
* | |
* @param string $current_letter | |
* | |
* @return string | |
* @throws \PhpOffice\PhpSpreadsheet\Exception | |
*/ | |
function excel_prev_letter($current_letter = 'A') | |
{ | |
$columnAlpha_index = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($current_letter); | |
$letter = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($columnAlpha_index - 1); | |
return $letter; | |
}//end excel_prev_letter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment