import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import java.io.*; public class Sample14_2{ public static void main(String[] args){ Workbook wb = new HSSFWorkbook(); Sheet sheet = wb.createSheet(); CellStyle style = wb.createCellStyle(); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.AQUA.getIndex()); for (int i = 0 ; i < 5000 ; i++){ Row row = sheet.createRow(i); Cell cell = row.createCell(1); cell.setCellValue("Test"); cell.setCellStyle(style); } FileOutputStream out = null; try{ out = new FileOutputStream("sample14_2.xls"); wb.write(out); }catch(IOException e){ System.out.println(e.toString()); }finally{ try { out.close(); }catch(IOException e){ System.out.println(e.toString()); } } } }