Merging cells in Excel by rows and columns together using PHPExcel

前端 未结 6 665
悲&欢浪女
悲&欢浪女 2021-02-05 10:25

I need to merge cells in Excel (xlsx) by rows and again by columns using PHPExcel. I tried the following.

$sheet->mergeCells(\"G\".($row_count+1).\":G\".($row         


        
6条回答
  •  醉话见心
    2021-02-05 10:59

    Merging simply requires a valid range of cells like A1:B2, so your

    $sheet->mergeCells("G".($row_count+1).":I".($row_count+1));
    

    should work without any problem.

    Can you please experiment with a simple test case to prove that this is causing you a problem, and not something else in your script

    EDIT

    After rereading your question: Your problem may be that you're trying to merge cells that are already part of a merge range, rather than merging each row, then trying to merge by column, try merging the full rangein one go.

    $sheet->mergeCells("G".($row_count+1).":I".($row_count+4));              
    

提交回复
热议问题