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.poifs.filesystem.POIFSFileSystem; 23 24 import java.io.IOException ; 25 import java.io.FileOutputStream ; 26 import java.io.FileInputStream ; 27 28 31 public class RepeatingRowsAndColumns 32 { 33 public static void main(String [] args) 34 throws IOException 35 { 36 HSSFWorkbook wb = new HSSFWorkbook(); 37 HSSFSheet sheet1 = wb.createSheet("first sheet"); 38 HSSFSheet sheet2 = wb.createSheet("second sheet"); 39 HSSFSheet sheet3 = wb.createSheet("third sheet"); 40 41 46 HSSFFont boldFont = wb.createFont(); 47 boldFont.setFontHeightInPoints((short)22); 48 boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); 49 50 HSSFCellStyle boldStyle = wb.createCellStyle(); 51 boldStyle.setFont(boldFont); 52 53 HSSFRow row = sheet1.createRow((short)1); 54 HSSFCell cell = row.createCell((short)0); 55 cell.setCellValue("This quick brown fox"); 56 cell.setCellStyle(boldStyle); 57 58 wb.setRepeatingRowsAndColumns(0,0,2,-1,-1); 60 wb.setRepeatingRowsAndColumns(1,-1,-1,0,2); 62 wb.setRepeatingRowsAndColumns(2,4,5,1,2); 64 65 FileOutputStream fileOut = new FileOutputStream ("workbook.xls"); 66 wb.write(fileOut); 67 fileOut.close(); 68 } 69 } 70 | Popular Tags |