Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

2.6K
Vistas
Merge and center cells in phpspreadsheet

im searching for hours in doc but got nothing to merge and horizontal center..

anyone can help me how to do this?

my last code :

$spreadsheet = new Spreadsheet();
$excel = $spreadsheet->getActiveSheet();
$spreadsheet->getProperties()->setTitle($name_sheet)->setCreator('Creator');

$excel->mergeCells('A1:W1');
$excel->mergeCells('A2:W2');
$excel->mergeCells('A3:W3');

//how to make cells A1 till W1 to be centered cell?
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

1

This is how y centered all the cells and format all borders.

$last_row = count($data) + 6;

$sheet->getStyle('A5:Y' . $last_row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
$sheet->getStyle('A5:Y' . $last_row)->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);

$borders = [
 'borders' => [
  'allBorders' => [
   'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
   'color' => ['argb' => '000'],
  ],
 ],
];

$sheet->getStyle('A5:Y' . $last_row)->applyFromArray($borders);
almost 4 years ago · Omar Crespo Carrazana Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda