Skip to content

Generating an array of column identifiers (e.g. A -> AA) #1802

Answered by pwaring
pwaring asked this question in Q&A
Discussion options

You must be logged in to vote

I eventually solved this via the use of columnIndexFromString and getHighestColumn:

$highest_column_index = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($worksheet->getHighestColumn(1));

foreach (range(1, $highest_column_index) as $column) {
    $worksheet->getCellByColumnAndRow($column, 1)->getStyle()->getFont()->setBold(true);
    $worksheet->getColumnDimensionByColumn($column)->setAutoSize(true);
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by pwaring
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants