1 2 17 18 19 package org.apache.poi.hssf.usermodel.examples; 20 21 import org.apache.poi.hssf.usermodel.*; 22 23 import java.io.FileOutputStream ; 24 import java.io.IOException ; 25 26 31 public class WorkingWithFonts 32 { 33 public static void main(String [] args) 34 throws IOException 35 { 36 HSSFWorkbook wb = new HSSFWorkbook(); 37 HSSFSheet sheet = wb.createSheet("new sheet"); 38 39 HSSFRow row = sheet.createRow((short) 1); 41 42 HSSFFont font = wb.createFont(); 44 font.setFontHeightInPoints((short)24); 45 font.setFontName("Courier New"); 46 font.setItalic(true); 47 font.setStrikeout(true); 48 49 HSSFCellStyle style = wb.createCellStyle(); 51 style.setFont(font); 52 53 HSSFCell cell = row.createCell((short) 1); 55 cell.setCellValue("This is a test of fonts"); 56 cell.setCellStyle(style); 57 58 FileOutputStream fileOut = new FileOutputStream ("workbook.xls"); 60 wb.write(fileOut); 61 fileOut.close(); 62 63 } 64 } 65 | Popular Tags |