1 2 17 18 19 package org.apache.poi.hssf.usermodel.examples; 20 21 import org.apache.poi.hssf.usermodel.*; 22 import org.apache.poi.hssf.util.Region; 23 24 import java.io.IOException ; 25 import java.io.FileOutputStream ; 26 27 32 public class MergedCells 33 { 34 public static void main(String [] args) 35 throws IOException 36 { 37 HSSFWorkbook wb = new HSSFWorkbook(); 38 HSSFSheet sheet = wb.createSheet("new sheet"); 39 40 HSSFRow row = sheet.createRow((short) 1); 41 HSSFCell cell = row.createCell((short) 1); 42 cell.setCellValue("This is a test of merging"); 43 44 sheet.addMergedRegion(new Region(1,(short)1,1,(short)2)); 45 46 FileOutputStream fileOut = new FileOutputStream ("workbook.xls"); 48 wb.write(fileOut); 49 fileOut.close(); 50 51 } 52 } 53 | Popular Tags |