rap-2-h rap-2-h - 2 months ago 19
PHP Question

Is there a built-in way to convert a column number to an Excel column with Laravel Excel

I want to add some style on a column using Laravel Excel. I know this column is the (let's say) 42nd, but I don't know the Excel code (like

AA
,
BC
, etc.).

I know I can build a function (based on this answer) to convert the column number to a letter, but I not sure it's the right way.

Is there a built-in way to convert a column number to an Excel column with Laravel Excel?

Answer

There is a method in PHPExcel and i guess Laravel Excel uses that library.

You can do like this:

\PHPExcel_Cell::stringFromColumnIndex(1);

This will return, B