是否有内置方法将列号转换为 Excel 列 Laravel Excel

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

我想使用 Laravel Excel 在列上添加一些样式。我知道这个专栏是(假设)第 42 个,但我不知道 Excel 代码(例如 AABC 等)。

我知道我可以构建一个函数(基于 this answer)将列号转换为字母,但我不确定这是正确的方法。

是否有一种内置方法可以将列号转换为具有 Laravel Excel 的 Excel 列?

PHPExcel 中有一个方法,我想 Laravel Excel 使用该库。

你可以这样做:

\PHPExcel_Cell::stringFromColumnIndex(1);

这将 return、B

version 3.1 of Laravel Excel is based off of the newest PHP Excel which uses the latest PhpSpreadsheet classes, the helper functions to manipulate coordinates have been moved to a new dedicated class. Search for "Dedicated class to manipulate coordinates" on this page.

因此,您可以继续这样做:

use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
...
Coordinate::stringFromColumnIndex(1);