Quantcast
Channel: PHPExcel Forum Rss Feed
Viewing all articles
Browse latest Browse all 2707

New Post: Data in column float to the right side

$
0
0
Hi there,

Excel and LibreOffice's Calc both apply cell alignment based on a cell's value if there is no cell style applied on that specific cell. In your case C1 is right-aligned because it contains a number whereas most other cells like C5 contain strings and are thus left-aligned. If you are going for left-aligned cell content, the easiest solution would be to prepend a single quote to the cell value which will cause Excel/Calc to see a string even if the cell contains a number (example: 1234 would become '1234).

Another way would be to add alignment programmatically:
$phpExcel->getActiveSheet()
    ->getStyle( $phpExcel->getActiveSheet()->calculateWorksheetDimension() )
    ->getAlignment()
    ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);  
(based on Mark's answer here: http://stackoverflow.com/questions/12614864/phpexcel-how-to-apply-alignment-for-the-whole-document-created-from-mysql-table )

Regards,

Sascha

Viewing all articles
Browse latest Browse all 2707

Trending Articles



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