PhpSeadsheets-如何按列和行获取单元格坐标



我想执行这个求和公式,但我正在用列和行填充单元格,如何获取最后一列的名称以将其放置在范围内

$sheet->setCellValueByColumnAndRow($col, $row, $score);
$sheet->setCellValueByColumnAndRow(($col + 1), $row, "=SUM(E{$row}:{$col_name}{$row})");
$sheet->getCellByColumnAndRow(($col + 1), $row)->getCalculatedValue();

我试过

$sheet->setCellValueByColumnAndRow($col, $row, "=SUM(E{$row}:{$sheet->getCellByColumnAndRow($col, $row)})");

我不能100%确定我理解这个需求,但假设我的解释是正确的,CellgetCoordinate()方法应该可以满足您的要求。试试这个:

$sheet->setCellValueByColumnAndRow($col, $row, "=SUM(E{$row}:{$sheet->getCellByColumnAndRow($col, $row)->getCoordinate()})");

最新更新