PHP Excel - Set cell or Column Direction (RTL)

微笑、不失礼 提交于 2019-12-04 06:32:13

问题


I'm looking for a way to set the "Direction" of a cell in Excel from PHP Excel. I've gone over any documentation i could find and found only the option to set the direction for a sheet, however, it does not affect the cell direction but rather, only the layout of the page from LTR to RTL.

I need to be able to set a specific Cell or better yet, a column, to be RTL.

Please note that I'm not talking about the alignment of the cell, I'm talking about the text direction.

this is not a duplication of Set direction sheet in PHPExcel

thanks


回答1:


This can only be set at the Worksheet level using

// right-to-left worksheet
$objPHPExcel->getActiveSheet()
    ->setRightToLeft(true);

not for individual cells, ranges of cells, columns or rows




回答2:


Got the answer to this by a dear friend (Bastien Koert) :

This takes care of the RTL for a single Cell.
    $objPHPExcel->getActiveSheet()->getStyle('J' , $i)->getAlignment()->setReadorder(PHPExcel_Style_Alignment::READORDER_RTL);

This takes care of the right alignment needed with Hebrew
    $objPHPExcel->getActiveSheet()->getStyle('J' , $i)->getAlignment()-  >setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);


来源:https://stackoverflow.com/questions/31422237/php-excel-set-cell-or-column-direction-rtl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!