This article demonstrates how to detect merged cells in an Excel worksheet and unmerge the merged cells using Spire.XLS for Java.
The input Excel file:

import com.spire.xls.CellRange;
import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;
public class DetectMergedCells {
public static void main(String[] args) throws Exception {
//Create a Workbook instance
Workbook workbook = new Workbook();
//Load the Excel file
workbook.loadFromFile( "Input.xlsx");
//Get the first worksheet
Worksheet sheet = workbook.getWorksheets().get(0);
//Get the merged cell ranges in the first worksheet and put them into a CellRange array
CellRange[] range = sheet.getMergedCells();
//Traverse through the array and unmerge the merged cells
for(CellRange cell : range){
cell.unMerge();
}
//Save the result file
workbook.saveToFile("DetectMergedCells.xlsx", ExcelVersion.Version2013);
}
}
The output Excel file:

