After the tutorial Merge Cells In Xlsx Files in PhpSpreadsheet, unmerging cells in xlsx files in PhpSpreadsheet is the next example to read. The file from Merge Cells In Xlsx Files will be used as a sample to unmerged the cells in an xlsx file.
Requirements:
- Composer
- PHP 7.2 or newer
Before Cell Unmerging

Step 1.
Setup dependencies.
{
"require": {
"phpoffice/phpspreadsheet": "^1.3"
}
}Step 2.
Install phpspreadsheet.
$ composer install
Step 3.
Create a new PHP file, and start coding.
<?php // Autoload dependencies require 'vendor/autoload.php'; // Import the IOFactory class use \PhpOffice\PhpSpreadsheet\IOFactory; // Import the Xlsx writer class use PhpOffice\PhpSpreadsheet\Writer\Xlsx; // Full path of the file to be indentified $inputFileName = 'merge-cells-in-xlsx-files.xlsx'; // Identify the file type using the IOFactory object $inputFileType = IOFactory::identify($inputFileName); // Create the reader object $reader = IOFactory::createReader($inputFileType); // Load the file to read $spreadsheet = $reader->load($inputFileName); // Retrieve the current active worksheet $sheet = $spreadsheet->getActiveSheet(); // Unmerge cells from A1 to D5 $sheet->unmergeCells('A1:D5'); // Write a new .xlsx file $writer = new Xlsx($spreadsheet); // Save the new .xlsx file $writer->save('unmerge-cells-in-xlsx-files.xlsx');
Test.
Run the following codes.
$ php unmerge-cells-in-xlsx-files.php
Result.
Open the generated file unmerge-cells-in-xlsx-files.xlsx.

References:
How to install PhpSpreadsheetOn this site
Create Xlsx Files With Different Cell Background ColorsOn this site
Read Xlsx Files Using IOFactory ClassOn this site
Creating a spreadsheetphpspreadsheet.readthedocs.io
Reading and writing to filephpspreadsheet.readthedocs.io
Reading Filesphpspreadsheet.readthedocs.io
PhpSpreadsheet Recipesphpspreadsheet.readthedocs.io
Merge/unmerge cellsphpspreadsheet.readthedocs.io