public class ExcelCell { public static boolean isMergedRegion(HSSFSheet sheet,int row ,int column) { int sheetMergeCount = sheet.getNumMergedRegions(); for (int i = 0; i < sheetMergeCount; i++) { Region ca = sheet.getMergedRegionAt(i); int firstColumn = ca.getColumnFrom(); int lastColumn = ca.getColumnTo(); int firstRow = ca.getRowFrom(); int lastRow = ca.getRowTo(); if(row >= firstRow && row <= lastRow) { if(column >= firstColumn && column <= lastColumn) { return true; } } } return false; }}
========================================================== ========
Rownum = sheet. getphysicalnumberofrows (); For (INT I = 7; I <rownum; I ++) {ROW = sheet. getrow (I); If (excelcell. ismergedregion (sheet, row. getrownum (), 1) {system. out. println ("merge cells, stop loops"); break;} Try {// get the Cell Object System. out. println (I + "" + row. getcell (0) + "=>" + row. getcell (0 ). getcellstyle (). getindention () + "*****" + row. getcell (1) + "" + row. getcell (2);} catch (exception e) {e. printstacktrace ();}}