private static void writeTestApachePoi() { String columnA = ""; String columnB = ""; String columnC = ""; String columnD = ""; String columnE = ""; String columnF = ""; String columnG = ""; String columnH = ""; Workbook workbook = new SXSSFWorkbook(100); Sheet sheet1 = workbook.createSheet("TEST REPORT"); Row dataRow = null; int rowNum = 1; Font font = (Font) workbook.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontName("Calibri"); font.setFontHeightInPoints((short) 10); CellStyle style = (CellStyle) workbook.createCellStyle(); style.setFont(font); style.setBorderRight(CellStyle.BORDER_THIN); style.setBorderBottom(CellStyle.BORDER_THIN); style.setAlignment(CellStyle.ALIGN_CENTER); Row row1 = sheet1.createRow(0); row1.createCell(0).setCellValue("COLUMN A "); row1.createCell(1).setCellValue("COLUMN B"); row1.createCell(2).setCellValue("COLUMN C"); row1.createCell(3).setCellValue("COLUMN D"); row1.createCell(4).setCellValue("COLUMN E"); row1.createCell(5).setCellValue("COLUMN F"); row1.createCell(6).setCellValue("COLUMN G"); row1.createCell(7).setCellValue("COLUMN H"); style.setBorderRight(CellStyle.BORDER_THIN); style.setBorderBottom(CellStyle.BORDER_THIN); for (int i=0; i<8; i++) { sheet1.autoSizeColumn(i); Cell cell1 = row1.getCell(i); cell1.setCellStyle(style); } for(int s=0; s<20; s++) { columnA = "COLUMNA" +String.valueOf(s); columnB = "COLUMNB" +String.valueOf(s); columnC = "COLUMNC" +String.valueOf(s); columnD = "COLUMND" +String.valueOf(s); columnE = "COLUMNE" +String.valueOf(s); columnF = "COLUMNF" +String.valueOf(s); columnG = "COLUMNG" +String.valueOf(s); columnH = "COLUMNH" +String.valueOf(s); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); String createDate = sdf.format(new Date()); dataRow = sheet1.createRow(rowNum); dataRow.createCell(0).setCellValue(columnA); dataRow.createCell(1).setCellValue(columnB); dataRow.createCell(2).setCellValue(columnC); dataRow.createCell(3).setCellValue(columnD); dataRow.createCell(4).setCellValue(columnE); dataRow.createCell(5).setCellValue(columnF); dataRow.createCell(6).setCellValue(columnG); dataRow.createCell(7).setCellValue(createDate); CellStyle style1 = (CellStyle) workbook.createCellStyle(); style1.setBorderRight(CellStyle.BORDER_THIN); for (int i=0; i<8; i++) { Cell cell1_1_1 = dataRow.getCell(i); cell1_1_1.setCellStyle(style1); } rowNum++; } try { FileOutputStream out = new FileOutputStream(new File("C:\\REPORT\\JDK.xlsx" )); workbook.write(out); out.close(); } catch(Exception e) { } }