PHPExcel and Text Wrapping

后端 未结 3 1915
借酒劲吻你
借酒劲吻你 2021-01-30 20:19

I know that this line of code will make the cell text-wrap:

$objPHPExcel->getActiveSheet()->getStyle(\'D1\')->getAlignment()->setWrapText(true);


        
相关标签:
3条回答
  • 2021-01-30 20:25
    $objPHPExcel->getDefaultStyle()->getAlignment()->setWrapText(true);
    
    0 讨论(0)
  • 2021-01-30 20:32

    Apply to a range:

    $objPHPExcel->getActiveSheet()->getStyle('D1:E999')
        ->getAlignment()->setWrapText(true); 
    

    Apply to a column

    $objPHPExcel->getActiveSheet()->getStyle('D1:D'.$objPHPExcel->getActiveSheet()->getHighestRow())
        ->getAlignment()->setWrapText(true); 
    
    0 讨论(0)
  • 2021-01-30 20:37

    Apply to column

    $highestRow = $$objPHPExcel->getActiveSheet()->getHighestRow();
    for ($row = 1; $row <= $highestRow; $row++){
        $sheet->getStyle("D$row")->getAlignment()->setWrapText(true);
    }
    
    0 讨论(0)
提交回复
热议问题