Created
February 18, 2022 22:56
-
-
Save dfelton/bac3e0f44482ffad66368ba9ab1f8a4e to your computer and use it in GitHub Desktop.
IMPORTRANGE() column generator of months of the years for Google Sheets
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
<?php | |
declare(strict_types=1); | |
$format = '"=IMPORTRANGE(""%s"",""%s!H1"")"'; | |
$months = [ | |
"JAN", | |
"FEB", | |
"MAR", | |
"APR", | |
"MAY", | |
"JUN", | |
"JUL", | |
"AUG", | |
"SEP", | |
"OCT", | |
"NOV", | |
"DEC", | |
]; | |
$sheets = [ | |
2031 => "foobar", | |
2032 => "fizzbuzz", | |
]; | |
$content = ''; | |
foreach ($sheets as $sheet) { | |
foreach ($months as $month) { | |
$content .= sprintf($format, $sheet, $month) . PHP_EOL; | |
} | |
} | |
file_put_contents('/tmp/results.csv', $content); | |
echo "Copy contents of '/tmp/results.csv' and paste into a Google Sheets cell the results." . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment