Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8037025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:48:09+00:00 2026-06-05T02:48:09+00:00

I need to merge cells in Excel (xlsx) by rows and again by columns

  • 0

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_count+4));             
$sheet->mergeCells("H".($row_count+1).":H".($row_count+4));             
$sheet->mergeCells("I".($row_count+1).":I".($row_count+4));     

Where the variable $row_count has some unpredictable dynamic value like 25, 50, 75 and so on (no regular pattern).

enter image description here

It merges the cells as shown in the preceding snap shot as can be seen immediately below the Note cell. After merging these cells by rows, I’m trying to merge them by columns as follows.

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

but it doesn’t work. When I try to open the excel file, it asks for a confirmation (with a confirmation box)

Excel found unreadable content in ‘report.xlsx’. Do you want to
recover the contents of this workbook? If you trust the source of this
workbook, click Yes.

How to merge cells by rows and columns together in Excel then?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:48:11+00:00Added an answer on June 5, 2026 at 2:48 am

    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));              
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to display an HTML with various cells merged across rows. Here's a
I need to merge any missing rows in a production mysql database from a
I need to merge two SELECT statements. There are two tables in my database,
I need to merge between dev and master frequently. I also have a commit
I need to merge two bitmaps to use the resulting bitmap as a mask.
I need to merge and sort lists of 100,000+ words lexicographically. I currently do
I need to write a java application which can merge docx files. Any suggestions?
All, I need your help to merge the result in the same datetime in
Say, I employ merge sort to sort an array of Integers. Now I need
Here’s a problem I’ve really been struggling with. I need to merge two sorted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.