如何 select 这个 maatwebsite laravel 中的所有单元格?

how to select all the cells in this maatwebsite laravel?

我正在尝试格式化我的单元格以居中对齐。在文档中只有 select 特定单元格和单元格范围的示例。我如何格式化整个 sheet 以使所有内容居中对齐?

$sheet->cells('A1:A5', function($cells) {

// manipulate the range of cells

});

我想select所有单元格而不是范围

您可以使用以下代码更改整个 excel sheet 的布局

 Excel::create('Filename', function($excel) {
 $excel->getDefaultStyle()
    ->getAlignment()
    ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER)
});

这将使所有单元格水平居中。要使它们垂直居中,请添加

Excel::create('Filename', function($excel) {
$excel->getDefaultStyle()
    ->getAlignment()
    ->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER)
});