import java.util.*; import java.io.*; import org.apache.poi.poifs.filesystem.*; import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.util.*; public class MergedRegionTest { public static void main(String[] args) throws Exception { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(); for (int y = 0; y < 5; y++) { HSSFRow row = sheet.createRow(y); for (short x = 0; x < 5; x++) { HSSFCell cell = row.createCell(x); cell.setCellValue(x + ":" + y); cell.setCellType(HSSFCell.CELL_TYPE_STRING); } } Region r1 = new Region(2, (short) 0, 2, (short) 4); sheet.addMergedRegion(r1); Region r2 = new Region(0, (short) 2, 4, (short) 2); sheet.addMergedRegion(r2); FileOutputStream out = new FileOutputStream("test.xls"); wb.write(out); out.flush(); out.close(); } }