Ratings | | Unique User Downloads | | Download Rankings |
Not enough user ratings | | Total: 12 | | All time: 11,474 This week: 51 |
|
Description | | Author |
This package can convert spreadsheet column letters to numbers. It can take a string as a parameter with the letters of the spreadsheet column. Then it returns the respective numbers of the column. The package can also do the opposite, i.e. covert a column number and return a string with the column letters. Innovation Award  June 2024 Number 3 | Spreadsheets are popular applications often used to show financial values in a table that users can modify to suit their purposes. Spreadsheet table columns have identifiers for the column position using letters. This package can convert the spreadsheet position letters to the respective number of the column. Manuel Lemos | | |  | | Innovation award
 Nominee: 4x
Winner: 1x |
|
Example
<?php require_once "vendor/autoload.php"; use IrisSG\Test\ExcelConverter; use IrisSG\Test\DisplayExcelColumns; // Check if at least one command-line argument is provided if (count($argv) < 2) { echo "Please provide at least one value to be converted as argument.\n"; exit(1); } $arguments = $argv; // lets remove the caller file array_shift($arguments); $converter = new ExcelConverter(); $convertedExcelColumnToConsole = new DisplayExcelColumns(); foreach($arguments as $argument) { echo $convertedExcelColumnToConsole->format( columnToBeConverted: $argument, conversionResult: (is_numeric($argument) ? $converter->numberToTitle($argument) : $converter->titleToNumber($argument)) ); } |
Details
Task Name: Excel Sheet Column Letter to Column Number And Vice Versa.
Pick from C#, JavaScript or PHP to complete this task, it can be done in any IDE.
- __PART 1__: Given a string (columnTitle) that represents the column title as it appears in an Excel sheet, return its corresponding column number.
Example:
| Input | Output | |-------|--------| | A | 1 | | B | 2 | | C | 3 | | Z | 26 | | AA | 27 | | AB | 28 |
- __PART 2__: Given a positive number, convert the number to the corresponding Excel column name.
Example:
| Input | Output | |-------|--------| | 26 | Z | | 51 | AY | | 52 | AZ | | 80 | CB | | 676 | YZ | | 702 | ZZ | | 705 | AAC |
Usage
Test from console
php ./index.php A 1 76 AAZ
Run test
./vendor/bin/phpunit ./tests/ExcelConverter/*
| Applications that use this package | |
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.