Quantcast
Channel: User totymedli - Stack Overflow
Viewing all articles
Browse latest Browse all 54

Answer by totymedli for How to middle align cell value in PhpSpreadsheet?

$
0
0

Beyond the style array way you can also do it in the method chaining way:

$spreadsheet->getActiveSheet()->getStyle($cells)->getAlignment()->setHorizontal($align)$spreadsheet->getActiveSheet()->getStyle($cells)->getAlignment()->setVertical($align);
  • $cells should be a single cell ('A1') or a range of cells ('A1:E4').
  • $align should be a constant of the \PhpOffice\PhpSpreadsheet\Style\Alignment class (or its string value) for the desired alignment.
    • for horizontal alignment:
      • Alignment::HORIZONTAL_GENERAL or 'general'
      • Alignment::HORIZONTAL_LEFT or 'left'
      • Alignment::HORIZONTAL_RIGHT or 'right'
      • Alignment::HORIZONTAL_CENTER or 'center'
      • Alignment::HORIZONTAL_CENTER_CONTINUOUS or 'centerContinuous'
      • Alignment::HORIZONTAL_JUSTIFY or 'justify'
      • Alignment::HORIZONTAL_FILL or 'fill'
      • Alignment::HORIZONTAL_DISTRIBUTED or 'distributed' (Excel2007 only)
    • for vertical alignment:
      • Alignment::VERTICAL_BOTTOM or 'bottom'
      • Alignment::VERTICAL_TOP or 'top'
      • Alignment::VERTICAL_CENTER or 'center'
      • Alignment::VERTICAL_JUSTIFY or 'justify'
      • Alignment::VERTICAL_DISTRIBUTED or 'distributed' (Excel2007 only)

The source of these is the source.


Viewing all articles
Browse latest Browse all 54

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>