Skip to content

Instantly share code, notes, and snippets.

@sharapeco
Last active December 8, 2022 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharapeco/942662b73e99328bcaf6be7d60ad72d8 to your computer and use it in GitHub Desktop.
Save sharapeco/942662b73e99328bcaf6be7d60ad72d8 to your computer and use it in GitHub Desktop.
PhpSpreadsheetを使うと欲しくなる関数
<?php
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
function coords(int $startCol, int $startRow, ?int $endCol = null, ?int $endRow = null): string
{
$coords = Coordinate::stringFromColumnIndex($startCol) . $startRow;
if (isset($endRow)) {
$coords .= ':' . Coordinate::stringFromColumnIndex($endCol) . $endRow;
}
return $coords;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment