I have to write texts in cells that are combinations of RTL and LTR languages inline and the prior language is the RTL one. So I need the text in xls file generated by PHPExcel to be RTL by default. What can I do?
Asked
Active
Viewed 1,478 times
1 Answers
4
To set direction for the entire worksheet, you can use:
$objPHPExcel->getActiveSheet()
->setRightToLeft(true);
For an individual cell (or range of cells) you can try:
// Set the character order as RTL
$objPHPExcel->getActiveSheet()
->getStyle('A1')
->getAlignment()
->setReadorder(PHPExcel_Style_Alignment::READORDER_RTL);
// Set cell alignment to the right
$objPHPExcel->getActiveSheet()
->getStyle('A1')
->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);

Mark Baker
- 209,507
- 32
- 346
- 385
-
Thanks, `PHPExcel_Style_Alignment::READORDER_RTL` worked for me. – Hedayatullah Sarwary Oct 23 '22 at 05:46